Code Coverage |
||||||||||||||||
Lines |
Branches |
Paths |
Functions and Methods |
Classes and Traits |
||||||||||||
| Total | |
100.00% |
9 / 9 |
|
100.00% |
3 / 3 |
|
100.00% |
3 / 3 |
|
100.00% |
3 / 3 |
CRAP | |
100.00% |
1 / 1 |
| ContactService | |
100.00% |
9 / 9 |
|
100.00% |
3 / 3 |
|
100.00% |
3 / 3 |
|
100.00% |
3 / 3 |
3 | |
100.00% |
1 / 1 |
| __construct | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
| save | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
| create | |
100.00% |
7 / 7 |
|
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
| 1 | <?php |
| 2 | |
| 3 | namespace App\Service\Data; |
| 4 | |
| 5 | use App\Dto\Command\CreateContactCommand; |
| 6 | use App\Entity\Contact; |
| 7 | use Doctrine\ORM\EntityManagerInterface; |
| 8 | use Psr\Clock\ClockInterface; |
| 9 | |
| 10 | /** |
| 11 | * @author Wilhelm Zwertvaegher |
| 12 | */ |
| 13 | readonly class ContactService implements ContactServiceInterface |
| 14 | { |
| 15 | public function __construct( |
| 16 | private EntityManagerInterface $entityManager, |
| 17 | private ClockInterface $clock, |
| 18 | ) { |
| 19 | } |
| 20 | |
| 21 | public function save(Contact $contact): void |
| 22 | { |
| 23 | $this->entityManager->persist($contact); |
| 24 | } |
| 25 | |
| 26 | public function create(CreateContactCommand $command): Contact |
| 27 | { |
| 28 | $contact = new Contact( |
| 29 | senderEmail: $command->getSenderEmail(), |
| 30 | content: $command->getContent(), |
| 31 | createdAt: $this->clock->now() |
| 32 | ); |
| 33 | |
| 34 | $this->save($contact); |
| 35 | |
| 36 | return $contact; |
| 37 | } |
| 38 | } |
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.
| 15 | public function __construct( |
| 16 | private EntityManagerInterface $entityManager, |
| 17 | private ClockInterface $clock, |
| 18 | ) { |
| 19 | } |
| 26 | public function create(CreateContactCommand $command): Contact |
| 27 | { |
| 28 | $contact = new Contact( |
| 29 | senderEmail: $command->getSenderEmail(), |
| 30 | content: $command->getContent(), |
| 31 | createdAt: $this->clock->now() |
| 32 | ); |
| 33 | |
| 34 | $this->save($contact); |
| 35 | |
| 36 | return $contact; |
| 37 | } |
| 21 | public function save(Contact $contact): void |
| 22 | { |
| 23 | $this->entityManager->persist($contact); |
| 24 | } |
| 3 | namespace App\Service\Data; |
| 4 | |
| 5 | use App\Dto\Command\CreateContactCommand; |
| 6 | use App\Entity\Contact; |
| 7 | use Doctrine\ORM\EntityManagerInterface; |
| 8 | use Psr\Clock\ClockInterface; |
| 9 | |
| 10 | /** |
| 11 | * @author Wilhelm Zwertvaegher |
| 12 | */ |
| 13 | readonly class ContactService implements ContactServiceInterface |
| 14 | { |
| 15 | public function __construct( |
| 16 | private EntityManagerInterface $entityManager, |
| 17 | private ClockInterface $clock, |
| 18 | ) { |
| 19 | } |
| 20 | |
| 21 | public function save(Contact $contact): void |
| 22 | { |
| 23 | $this->entityManager->persist($contact); |
| 24 | } |
| 25 | |
| 26 | public function create(CreateContactCommand $command): Contact |
| 27 | { |
| 28 | $contact = new Contact( |
| 29 | senderEmail: $command->getSenderEmail(), |
| 30 | content: $command->getContent(), |
| 31 | createdAt: $this->clock->now() |
| 32 | ); |
| 33 | |
| 34 | $this->save($contact); |
| 35 | |
| 36 | return $contact; |
| 37 | } |