Code Coverage
 
Lines
Branches
Paths
Functions and Methods
Classes and Traits
Total
100.00% covered (success)
100.00%
5 / 5
100.00% covered (success)
100.00%
2 / 2
100.00% covered (success)
100.00%
2 / 2
100.00% covered (success)
100.00%
2 / 2
CRAP
100.00% covered (success)
100.00%
1 / 1
HtmlNotificationRenderer
100.00% covered (success)
100.00%
5 / 5
100.00% covered (success)
100.00%
2 / 2
100.00% covered (success)
100.00%
2 / 2
100.00% covered (success)
100.00%
2 / 2
2
100.00% covered (success)
100.00%
1 / 1
 __construct
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
1
 render
100.00% covered (success)
100.00%
4 / 4
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
1
1<?php
2
3namespace App\Service\Notification\Renderer;
4
5use App\Entity\Notification;
6use App\Service\Notification\Sender\NotificationSenderInterface;
7use Twig\Environment;
8
9/**
10 * @author Wilhelm Zwertvaegher
11 */
12readonly class HtmlNotificationRenderer 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/'.$sender->getName().'/'.$notification->getType()->value.'.html.twig',
23            ['content' => $notification->getContent(), 'date' => $notification->getCreatedAt()]
24        );
25    }
26}