Code Coverage |
||||||||||||||||
Lines |
Branches |
Paths |
Functions and Methods |
Classes and Traits |
||||||||||||
| Total | |
100.00% |
4 / 4 |
|
60.00% |
3 / 5 |
|
50.00% |
1 / 2 |
|
0.00% |
0 / 1 |
CRAP | |
0.00% |
0 / 1 |
| DefaultNotificationSubjectGenerator | |
100.00% |
4 / 4 |
|
60.00% |
3 / 5 |
|
50.00% |
1 / 2 |
|
100.00% |
1 / 1 |
4.12 | |
100.00% |
1 / 1 |
| generate | |
100.00% |
4 / 4 |
|
60.00% |
3 / 5 |
|
50.00% |
1 / 2 |
|
100.00% |
1 / 1 |
4.12 | |||
| 1 | <?php |
| 2 | |
| 3 | namespace App\Notification\Infrastructure\Renderer; |
| 4 | |
| 5 | use App\Notification\Domain\Exception\UnknownNotificationTypeException; |
| 6 | use App\Notification\Domain\Model\Notification; |
| 7 | use App\Notification\Domain\Model\NotificationType; |
| 8 | |
| 9 | /** |
| 10 | * @author Wilhelm Zwertvaegher |
| 11 | */ |
| 12 | class DefaultNotificationSubjectGenerator implements NotificationSubjectGenerator |
| 13 | { |
| 14 | |
| 15 | /** |
| 16 | * @throws UnknownNotificationTypeException |
| 17 | */ |
| 18 | public function generate(Notification $notification): string |
| 19 | { |
| 20 | return match ($notification->getType()) { |
| 21 | NotificationType::WELCOME => 'Welcome ' . $notification->getIdentityInfo()->getUsername(), |
| 22 | default => throw new UnknownNotificationTypeException() |
| 23 | }; |
| 24 | } |
| 25 | } |