Passed
Branch master (2117c8)
by Hirofumi
97:26 queued 41:41
created

EmailNotSentException::__construct()   A

Complexity

Conditions 3
Paths 4

Size

Total Lines 9

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 6
CRAP Score 3.0261

Importance

Changes 0
Metric Value
cc 3
nc 4
nop 2
dl 0
loc 9
ccs 6
cts 7
cp 0.8571
crap 3.0261
rs 9.9666
c 0
b 0
f 0
1
<?php
2
declare(strict_types=1);
3
4
namespace Shippinno\Email;
5
6
use Exception;
7
use Throwable;
8
9
class EmailNotSentException extends Exception
10
{
11
    /**
12
     * @var array
13
     */
14
    private $recipients;
15
16
    /**
17
     * @param array|null $recipients
18
     * @param Throwable|null $previous
19
     */
20 2
    public function __construct(?array $recipients = [], Throwable $previous = null)
21
    {
22 2
        $this->recipients = is_null($recipients) ? [] : $recipients;
23 2
        $message = 'Failed to send email.';
24 2
        if (count($recipients) > 0) {
25
            $message .= ' Recipients: ' . implode(', ', $this->recipients());
26
        }
27 2
        parent::__construct($message, 0, $previous);
28 2
    }
29
30
    /**
31
     * @return string[]
32
     */
33
    public function recipients(): array
34
    {
35
        return $this->recipients;
36
    }
37
}
38