Code Coverage |
||||||||||
Classes and Traits |
Functions and Methods |
Lines |
||||||||
| Total | |
0.00% |
0 / 1 |
|
33.33% |
1 / 3 |
CRAP | |
13.33% |
2 / 15 |
| UserRepository | |
0.00% |
0 / 1 |
|
33.33% |
1 / 3 |
29.43 | |
13.33% |
2 / 15 |
| ref | |
100.00% |
1 / 1 |
1 | |
100.00% |
2 / 2 |
|||
| findByUserName | |
0.00% |
0 / 1 |
6 | |
0.00% |
0 / 8 |
|||
| findAll | |
0.00% |
0 / 1 |
12 | |
0.00% |
0 / 5 |
|||
| <?php declare(strict_types = 1); | |
| /* | |
| * Copyright (c) 2019, Josef Kufner <josef@kufner.cz> | |
| * | |
| * Licensed under the Apache License, Version 2.0 (the "License"); | |
| * you may not use this file except in compliance with the License. | |
| * You may obtain a copy of the License at | |
| * | |
| * http://www.apache.org/licenses/LICENSE-2.0 | |
| * | |
| * Unless required by applicable law or agreed to in writing, software | |
| * distributed under the License is distributed on an "AS IS" BASIS, | |
| * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | |
| * See the License for the specific language governing permissions and | |
| * limitations under the License. | |
| * | |
| */ | |
| namespace Smalldb\StateMachine\Test\Example\User; | |
| use Smalldb\SmalldbBundle\Security\UserRepositoryInterface; | |
| use Smalldb\StateMachine\SmalldbRepositoryInterface; | |
| use Smalldb\StateMachine\SqlExtension\AbstractSqlRepository; | |
| use Smalldb\StateMachine\SqlExtension\ReferenceDataSource\ReferenceQueryResult; | |
| class UserRepository extends AbstractSqlRepository implements SmalldbRepositoryInterface /* UserRepositoryInterface */ | |
| { | |
| protected const REF_CLASS = User::class; | |
| public function ref($id): User | |
| { | |
| /** @var User $ref */ | |
| $ref = $this->getDataSource()->ref($id); | |
| return $ref; | |
| } | |
| public function findByUserName(string $username): ?User | |
| { | |
| $q = $this->getDataSource()->createQueryBuilder() | |
| ->addSelectFromStatements(); | |
| $q->where('username = :username'); | |
| $q->setMaxResults(1); | |
| $q->setParameter('username', $username); | |
| $result = $q->executeRef(); | |
| /** @var User|null $ref */ | |
| $ref = $result->fetch(); | |
| return $ref; | |
| } | |
| public function findAll(?int $maxResults): ReferenceQueryResult | |
| { | |
| $q = $this->createQueryBuilder(); | |
| $q->orderBy('id', 'DESC'); | |
| if ($maxResults !== null) { | |
| $q->setMaxResults($maxResults); | |
| } | |
| return $q->executeRef(); | |
| } | |
| } | |