Code Coverage |
||||||||||||||||
Lines |
Branches |
Paths |
Functions and Methods |
Classes and Traits |
||||||||||||
| Total | |
100.00% |
7 / 7 |
|
100.00% |
2 / 2 |
|
100.00% |
2 / 2 |
|
100.00% |
2 / 2 |
CRAP | |
100.00% |
1 / 1 |
| TextNotificationRenderer | |
100.00% |
7 / 7 |
|
100.00% |
2 / 2 |
|
100.00% |
2 / 2 |
|
100.00% |
2 / 2 |
2 | |
100.00% |
1 / 1 |
| __construct | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
| render | |
100.00% |
6 / 6 |
|
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
| 1 | <?php |
| 2 | |
| 3 | namespace App\Service\Notification\Renderer; |
| 4 | |
| 5 | use App\Entity\Notification; |
| 6 | use App\Service\Notification\Sender\NotificationSenderInterface; |
| 7 | use Twig\Environment; |
| 8 | |
| 9 | /** |
| 10 | * @author Wilhelm Zwertvaegher |
| 11 | */ |
| 12 | class TextNotificationRenderer implements NotificationRendererInterface |
| 13 | { |
| 14 | public function __construct( |
| 15 | private Environment $twig, |
| 16 | ) { |
| 17 | } |
| 18 | |
| 19 | public function render(Notification $notification, NotificationSenderInterface $sender): string |
| 20 | { |
| 21 | return $this->twig->render( |
| 22 | 'notifications/' |
| 23 | .$sender->getName().'/' |
| 24 | .$notification->getType()->value.'.txt.twig', |
| 25 | ['content' => $notification->getContent(), 'date' => $notification->getCreatedAt()] |
| 26 | ); |
| 27 | } |
| 28 | } |