Code Coverage
 
Lines
Branches
Paths
Functions and Methods
Classes and Traits
Total
23.08% covered (danger)
23.08%
3 / 13
50.00% covered (danger)
50.00%
3 / 6
60.00% covered (warning)
60.00%
3 / 5
75.00% covered (warning)
75.00%
3 / 4
CRAP
0.00% covered (danger)
0.00%
0 / 1
SmsSender
23.08% covered (danger)
23.08%
3 / 13
50.00% covered (danger)
50.00%
3 / 6
60.00% covered (warning)
60.00%
3 / 5
75.00% covered (warning)
75.00%
3 / 4
6.60
0.00% covered (danger)
0.00%
0 / 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
 supports
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
 send
0.00% covered (danger)
0.00%
0 / 10
0.00% covered (danger)
0.00%
0 / 3
0.00% covered (danger)
0.00%
0 / 2
0.00% covered (danger)
0.00%
0 / 1
6
 getName
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
1<?php
2
3namespace App\Notification\Infrastructure\Sender;
4
5use App\Notification\Domain\Model\Notification;
6use App\Notification\Domain\Model\NotificationStatus;
7use App\Notification\Domain\Model\NotificationType;
8use App\Notification\Infrastructure\Renderer\NotificationRenderer;
9use Symfony\Component\Notifier\Exception\TransportExceptionInterface;
10use Symfony\Component\Notifier\Message\SmsMessage;
11use Symfony\Component\Notifier\TexterInterface;
12
13/**
14 * @author Wilhelm Zwertvaegher
15 */
16final 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}

Branches

Below are the source code lines that represent each code branch as identified by Xdebug. Please note a branch is not necessarily coterminous with a line, a line may contain multiple branches and therefore show up more than once. Please also be aware that some branches may be implicit rather than explicit, e.g. an if statement always has an else as part of its logical flow even if you didn't write one.

SmsSender->__construct
21    public function __construct(
22        private readonly NotificationRenderer $textRenderer,
23        private readonly TexterInterface      $texter
24    ) {
25    }
SmsSender->getName
52        return self::NAME;
53    }
SmsSender->send
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    }
SmsSender->supports
27    public function supports(Notification $notification): bool
28    {
29        return false;
30    }
{main}
3namespace App\Notification\Infrastructure\Sender;
4
5use App\Notification\Domain\Model\Notification;
6use App\Notification\Domain\Model\NotificationStatus;
7use App\Notification\Domain\Model\NotificationType;
8use App\Notification\Infrastructure\Renderer\NotificationRenderer;
9use Symfony\Component\Notifier\Exception\TransportExceptionInterface;
10use Symfony\Component\Notifier\Message\SmsMessage;
11use Symfony\Component\Notifier\TexterInterface;
12
13/**
14 * @author Wilhelm Zwertvaegher
15 */
16final 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    }