Passed
Push — 3.x ( bcfcb8...c4d50e )
by Eduardo Gulias
06:26 queued 13s
created

MultipleErrors::description()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 9

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 5
CRAP Score 2

Importance

Changes 0
Metric Value
dl 0
loc 9
ccs 5
cts 5
cp 1
rs 9.9666
c 0
b 0
f 0
cc 2
nc 2
nop 0
crap 2
1
<?php
2
3
namespace Egulias\EmailValidator\Result;
4
5
use Egulias\EmailValidator\Result\InvalidEmail;
6
use Egulias\EmailValidator\Result\Reason\Reason;
7
8
/**
9
 * @psalm-suppress PropertyNotSetInConstructor
10
 */
11
class MultipleErrors extends InvalidEmail
12
{
13
    /**
14
     * @var Reason[]
15
     */
16
    private $reasons = [];
17
18 8
    public function __construct()
19
    {
20 8
    }
21
22 8
    public function addReason(Reason $reason) : void
23
    {
24 8
        $this->reasons[$reason->code()] = $reason;
25 8
    }
26
27
    /**
28
     * @return Reason[]
29
     */
30 2
    public function getReasons() : array
31
    {
32 2
        return $this->reasons;
33
    }
34
35 1
    public function reason() : Reason
36
    {
37 1
        return $this->reasons[0];
38
    }
39
40 1
    public function description() : string
41
    {
42 1
        $description = '';
43 1
        foreach($this->reasons as $reason) {
44 1
            $description .= $reason->description() . PHP_EOL;
45
        }
46
47 1
        return $description;
48
    }
49
50
    public function code() : int
51
    {
52
        return 0;
53
    }
54
}
55