Passed
Push — master ( b9ffdf...6f7a22 )
by Hirofumi
04:56
created

NotificationNotSentException::notification()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 0
Metric Value
dl 0
loc 4
ccs 0
cts 2
cp 0
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 0
crap 2
1
<?php
2
3
namespace Shippinno\Notification\Domain\Model;
4
5
use DateTime;
6
use Exception;
7
use Throwable;
8
9
class NotificationNotSentException extends Exception
10
{
11
    /**
12
     * @var Notification
13
     */
14
    private $notification;
15
16
    /**
17
     * @param Notification $notification
18
     * @param Throwable|null $previous
19
     */
20 1
    public function __construct(Notification $notification, Throwable $previous = null)
21
    {
22 1
        $this->notification = $notification;
23 1
        parent::__construct(
24 1
            sprintf(
25 1
                'Failed to send notification: "%s" created at %s',
26 1
                $notification->subject()->subject(),
27 1
                $notification->createdAt()->format(DateTime::W3C)
28
            ),
29 1
            0,
30 1
            $previous
31
        );
32 1
    }
33
34
    /**
35
     * @return Notification
36
     */
37
    public function notification(): Notification
38
    {
39
        return $this->notification;
40
    }
41
}
42