Code Coverage |
||||||||||||||||
Lines |
Branches |
Paths |
Functions and Methods |
Classes and Traits |
||||||||||||
| Total | |
23.08% |
3 / 13 |
|
50.00% |
3 / 6 |
|
60.00% |
3 / 5 |
|
75.00% |
3 / 4 |
CRAP | |
0.00% |
0 / 1 |
| SmsSender | |
23.08% |
3 / 13 |
|
50.00% |
3 / 6 |
|
60.00% |
3 / 5 |
|
75.00% |
3 / 4 |
6.60 | |
0.00% |
0 / 1 |
| __construct | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
| supports | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
| send | |
0.00% |
0 / 10 |
|
0.00% |
0 / 3 |
|
0.00% |
0 / 2 |
|
0.00% |
0 / 1 |
6 | |||
| getName | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
| 1 | <?php |
| 2 | |
| 3 | namespace App\Notification\Infrastructure\Sender; |
| 4 | |
| 5 | use App\Notification\Domain\Model\Notification; |
| 6 | use App\Notification\Domain\Model\NotificationStatus; |
| 7 | use App\Notification\Domain\Model\NotificationType; |
| 8 | use App\Notification\Infrastructure\Renderer\NotificationRenderer; |
| 9 | use Symfony\Component\Notifier\Exception\TransportExceptionInterface; |
| 10 | use Symfony\Component\Notifier\Message\SmsMessage; |
| 11 | use Symfony\Component\Notifier\TexterInterface; |
| 12 | |
| 13 | /** |
| 14 | * @author Wilhelm Zwertvaegher |
| 15 | */ |
| 16 | final class SmsSender implements NotificationSender |
| 17 | { |
| 18 | |
| 19 | private const string NAME = 'sms'; |
| 20 | |
| 21 | public function __construct( |
| 22 | private readonly NotificationRenderer $textRenderer, |
| 23 | private readonly TexterInterface $texter |
| 24 | ) { |
| 25 | } |
| 26 | |
| 27 | public function supports(Notification $notification): bool |
| 28 | { |
| 29 | return false; |
| 30 | } |
| 31 | |
| 32 | public function send(Notification $notification): NotificationSenderResult |
| 33 | { |
| 34 | $content = $this->textRenderer->render($notification, $this); |
| 35 | |
| 36 | $smsNotification = new SmsMessage( |
| 37 | '+336123456789', |
| 38 | $content, |
| 39 | '+336123456789' |
| 40 | ); |
| 41 | |
| 42 | try { |
| 43 | $this->texter->send($smsNotification); |
| 44 | return new NotificationSenderResult(NotificationStatus::SENT, 'Sms sent : ' . $content); |
| 45 | } catch (TransportExceptionInterface $e) { |
| 46 | return new NotificationSenderResult(NotificationStatus::ERROR, 'Sms could not be send : ' . $e->getMessage()); |
| 47 | } |
| 48 | } |
| 49 | |
| 50 | public function getName(): string |
| 51 | { |
| 52 | return self::NAME; |
| 53 | } |
| 54 | } |
Below are the source code lines that represent each code path as identified by Xdebug. Please note a path is not
necessarily coterminous with a line, a line may contain multiple paths and therefore show up more than once.
Please also be aware that some paths may include implicit rather than explicit branches, e.g. an if statement
always has an else as part of its logical flow even if you didn't write one.
| 21 | public function __construct( |
| 22 | private readonly NotificationRenderer $textRenderer, |
| 23 | private readonly TexterInterface $texter |
| 24 | ) { |
| 25 | } |
| 52 | return self::NAME; |
| 53 | } |
| 32 | public function send(Notification $notification): NotificationSenderResult |
| 33 | { |
| 34 | $content = $this->textRenderer->render($notification, $this); |
| 35 | |
| 36 | $smsNotification = new SmsMessage( |
| 37 | '+336123456789', |
| 38 | $content, |
| 39 | '+336123456789' |
| 40 | ); |
| 41 | |
| 42 | try { |
| 43 | $this->texter->send($smsNotification); |
| 44 | return new NotificationSenderResult(NotificationStatus::SENT, 'Sms sent : ' . $content); |
| 45 | } catch (TransportExceptionInterface $e) { |
| 46 | return new NotificationSenderResult(NotificationStatus::ERROR, 'Sms could not be send : ' . $e->getMessage()); |
| 47 | } |
| 48 | } |
| 27 | public function supports(Notification $notification): bool |
| 28 | { |
| 29 | return false; |
| 30 | } |
| 3 | namespace App\Notification\Infrastructure\Sender; |
| 4 | |
| 5 | use App\Notification\Domain\Model\Notification; |
| 6 | use App\Notification\Domain\Model\NotificationStatus; |
| 7 | use App\Notification\Domain\Model\NotificationType; |
| 8 | use App\Notification\Infrastructure\Renderer\NotificationRenderer; |
| 9 | use Symfony\Component\Notifier\Exception\TransportExceptionInterface; |
| 10 | use Symfony\Component\Notifier\Message\SmsMessage; |
| 11 | use Symfony\Component\Notifier\TexterInterface; |
| 12 | |
| 13 | /** |
| 14 | * @author Wilhelm Zwertvaegher |
| 15 | */ |
| 16 | final class SmsSender implements NotificationSender |
| 17 | { |
| 18 | |
| 19 | private const string NAME = 'sms'; |
| 20 | |
| 21 | public function __construct( |
| 22 | private readonly NotificationRenderer $textRenderer, |
| 23 | private readonly TexterInterface $texter |
| 24 | ) { |
| 25 | } |
| 26 | |
| 27 | public function supports(Notification $notification): bool |
| 28 | { |
| 29 | return false; |
| 30 | } |
| 31 | |
| 32 | public function send(Notification $notification): NotificationSenderResult |
| 33 | { |
| 34 | $content = $this->textRenderer->render($notification, $this); |
| 35 | |
| 36 | $smsNotification = new SmsMessage( |
| 37 | '+336123456789', |
| 38 | $content, |
| 39 | '+336123456789' |
| 40 | ); |
| 41 | |
| 42 | try { |
| 43 | $this->texter->send($smsNotification); |
| 44 | return new NotificationSenderResult(NotificationStatus::SENT, 'Sms sent : ' . $content); |
| 45 | } catch (TransportExceptionInterface $e) { |
| 46 | return new NotificationSenderResult(NotificationStatus::ERROR, 'Sms could not be send : ' . $e->getMessage()); |
| 47 | } |
| 48 | } |
| 49 | |
| 50 | public function getName(): string |
| 51 | { |
| 52 | return self::NAME; |
| 53 | } |