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 |
| SuggestionService | |
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\CreateSuggestionCommand; |
| 6 | use App\Entity\Suggestion; |
| 7 | use Doctrine\ORM\EntityManagerInterface; |
| 8 | use Psr\Clock\ClockInterface; |
| 9 | |
| 10 | /** |
| 11 | * @author Wilhelm Zwertvaegher |
| 12 | */ |
| 13 | readonly class SuggestionService implements SuggestionServiceInterface |
| 14 | { |
| 15 | public function __construct( |
| 16 | private EntityManagerInterface $entityManager, |
| 17 | private ClockInterface $clock, |
| 18 | ) { |
| 19 | } |
| 20 | |
| 21 | public function save(Suggestion $suggestion): void |
| 22 | { |
| 23 | $this->entityManager->persist($suggestion); |
| 24 | } |
| 25 | |
| 26 | public function create(CreateSuggestionCommand $command): Suggestion |
| 27 | { |
| 28 | $suggestion = new Suggestion( |
| 29 | creatorEmail: $command->getSenderEmail(), |
| 30 | label: $command->getLabel(), |
| 31 | createdAt: $this->clock->now() |
| 32 | ); |
| 33 | |
| 34 | $this->save($suggestion); |
| 35 | |
| 36 | return $suggestion; |
| 37 | } |
| 38 | } |