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