Code Coverage |
||||||||||||||||
Lines |
Branches |
Paths |
Functions and Methods |
Classes and Traits |
||||||||||||
| Total | |
75.00% |
6 / 8 |
|
85.71% |
6 / 7 |
|
80.00% |
4 / 5 |
|
75.00% |
3 / 4 |
CRAP | |
0.00% |
0 / 1 |
| DoctrineUserRepository | |
75.00% |
6 / 8 |
|
85.71% |
6 / 7 |
|
80.00% |
4 / 5 |
|
75.00% |
3 / 4 |
5.20 | |
0.00% |
0 / 1 |
| __construct | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
| findById | |
0.00% |
0 / 2 |
|
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
| save | |
100.00% |
3 / 3 |
|
100.00% |
4 / 4 |
|
100.00% |
2 / 2 |
|
100.00% |
1 / 1 |
2 | |||
| findByIdentityId | |
100.00% |
2 / 2 |
|
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
| 1 | <?php |
| 2 | |
| 3 | namespace App\User\Infrastructure\Persistence\Doctrine\Repository; |
| 4 | |
| 5 | use App\Shared\Domain\Model\EntityId; |
| 6 | use App\Shared\Infrastructure\Persistence\Doctrine\Entity\DoctrineStoredFile; |
| 7 | use App\User\Domain\Model\User; |
| 8 | use App\User\Domain\Port\Driven\UserRepository; |
| 9 | use App\User\Infrastructure\Persistence\Doctrine\Entity\DoctrineUser; |
| 10 | use Doctrine\Bundle\DoctrineBundle\Repository\ServiceEntityRepository; |
| 11 | use Doctrine\ORM\EntityManagerInterface; |
| 12 | use Doctrine\Persistence\ManagerRegistry; |
| 13 | |
| 14 | /** |
| 15 | * @author Wilhelm Zwertvaegher |
| 16 | * @extends ServiceEntityRepository<DoctrineUser> |
| 17 | */ |
| 18 | class DoctrineUserRepository extends ServiceEntityRepository implements UserRepository |
| 19 | { |
| 20 | public function __construct(ManagerRegistry $managerRegistry, private readonly EntityManagerInterface $entityManager) |
| 21 | { |
| 22 | parent::__construct($managerRegistry, DoctrineUser::class); |
| 23 | } |
| 24 | |
| 25 | public function findById(EntityId $userId): ?User |
| 26 | { |
| 27 | $user = $this->find($userId->__toString()); |
| 28 | return $user?->toDomain(); |
| 29 | } |
| 30 | |
| 31 | public function save(User $user): void |
| 32 | { |
| 33 | $doctrineUser = $this->find($user->getId()) ?? new DoctrineUser(); |
| 34 | $doctrineUser->fromDomain($user, $user->getAvatar() ? $this->entityManager->find(DoctrineStoredFile::class, $user->getAvatar()->getId()) : null); |
| 35 | $this->entityManager->persist($doctrineUser); |
| 36 | } |
| 37 | |
| 38 | public function findByIdentityId(EntityId $identityId): ?User |
| 39 | { |
| 40 | $user = parent::findOneBy(['identityId' => (string)$identityId]); |
| 41 | return $user?->toDomain(); |
| 42 | } |
| 43 | } |
Below are the source code lines that represent each code path as identified by Xdebug. Please note a path is not
necessarily coterminous with a line, a line may contain multiple paths and therefore show up more than once.
Please also be aware that some paths may include implicit rather than explicit branches, e.g. an if statement
always has an else as part of its logical flow even if you didn't write one.
| 20 | public function __construct(ManagerRegistry $managerRegistry, private readonly EntityManagerInterface $entityManager) |
| 21 | { |
| 22 | parent::__construct($managerRegistry, DoctrineUser::class); |
| 23 | } |
| 25 | public function findById(EntityId $userId): ?User |
| 26 | { |
| 27 | $user = $this->find($userId->__toString()); |
| 28 | return $user?->toDomain(); |
| 29 | } |
| 38 | public function findByIdentityId(EntityId $identityId): ?User |
| 39 | { |
| 40 | $user = parent::findOneBy(['identityId' => (string)$identityId]); |
| 41 | return $user?->toDomain(); |
| 42 | } |
| 31 | public function save(User $user): void |
| 32 | { |
| 33 | $doctrineUser = $this->find($user->getId()) ?? new DoctrineUser(); |
| 34 | $doctrineUser->fromDomain($user, $user->getAvatar() ? $this->entityManager->find(DoctrineStoredFile::class, $user->getAvatar()->getId()) : null); |
| 34 | $doctrineUser->fromDomain($user, $user->getAvatar() ? $this->entityManager->find(DoctrineStoredFile::class, $user->getAvatar()->getId()) : null); |
| 34 | $doctrineUser->fromDomain($user, $user->getAvatar() ? $this->entityManager->find(DoctrineStoredFile::class, $user->getAvatar()->getId()) : null); |
| 35 | $this->entityManager->persist($doctrineUser); |
| 36 | } |
| 31 | public function save(User $user): void |
| 32 | { |
| 33 | $doctrineUser = $this->find($user->getId()) ?? new DoctrineUser(); |
| 34 | $doctrineUser->fromDomain($user, $user->getAvatar() ? $this->entityManager->find(DoctrineStoredFile::class, $user->getAvatar()->getId()) : null); |
| 34 | $doctrineUser->fromDomain($user, $user->getAvatar() ? $this->entityManager->find(DoctrineStoredFile::class, $user->getAvatar()->getId()) : null); |
| 34 | $doctrineUser->fromDomain($user, $user->getAvatar() ? $this->entityManager->find(DoctrineStoredFile::class, $user->getAvatar()->getId()) : null); |
| 35 | $this->entityManager->persist($doctrineUser); |
| 36 | } |
| 3 | namespace App\User\Infrastructure\Persistence\Doctrine\Repository; |
| 4 | |
| 5 | use App\Shared\Domain\Model\EntityId; |
| 6 | use App\Shared\Infrastructure\Persistence\Doctrine\Entity\DoctrineStoredFile; |
| 7 | use App\User\Domain\Model\User; |
| 8 | use App\User\Domain\Port\Driven\UserRepository; |
| 9 | use App\User\Infrastructure\Persistence\Doctrine\Entity\DoctrineUser; |
| 10 | use Doctrine\Bundle\DoctrineBundle\Repository\ServiceEntityRepository; |
| 11 | use Doctrine\ORM\EntityManagerInterface; |
| 12 | use Doctrine\Persistence\ManagerRegistry; |
| 13 | |
| 14 | /** |
| 15 | * @author Wilhelm Zwertvaegher |
| 16 | * @extends ServiceEntityRepository<DoctrineUser> |
| 17 | */ |
| 18 | class DoctrineUserRepository extends ServiceEntityRepository implements UserRepository |
| 19 | { |
| 20 | public function __construct(ManagerRegistry $managerRegistry, private readonly EntityManagerInterface $entityManager) |
| 21 | { |
| 22 | parent::__construct($managerRegistry, DoctrineUser::class); |
| 23 | } |
| 24 | |
| 25 | public function findById(EntityId $userId): ?User |
| 26 | { |
| 27 | $user = $this->find($userId->__toString()); |
| 28 | return $user?->toDomain(); |
| 29 | } |
| 30 | |
| 31 | public function save(User $user): void |
| 32 | { |
| 33 | $doctrineUser = $this->find($user->getId()) ?? new DoctrineUser(); |
| 34 | $doctrineUser->fromDomain($user, $user->getAvatar() ? $this->entityManager->find(DoctrineStoredFile::class, $user->getAvatar()->getId()) : null); |
| 35 | $this->entityManager->persist($doctrineUser); |
| 36 | } |
| 37 | |
| 38 | public function findByIdentityId(EntityId $identityId): ?User |
| 39 | { |
| 40 | $user = parent::findOneBy(['identityId' => (string)$identityId]); |
| 41 | return $user?->toDomain(); |
| 42 | } |