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

EmailNotSentException   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 29
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 0

Test Coverage

Coverage 66.67%

Importance

Changes 0
Metric Value
dl 0
loc 29
ccs 6
cts 9
cp 0.6667
rs 10
c 0
b 0
f 0
wmc 4
lcom 0
cbo 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 9 3
A recipients() 0 4 1
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