Test Setup Failed
Push — 3.0.0-dev ( b76c11...98ebd5 )
by Eduardo Gulias
01:52
created

MultipleErrors::description()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 9

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 9
rs 9.9666
c 0
b 0
f 0
cc 2
nc 2
nop 0
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
    public function __construct()
19
    {
20
    }
21
22
    public function addReason(Reason $reason)
23
    {
24
        $this->reasons[$reason->code()] = $reason;
25
    }
26
27
    /**
28
     * @return Reason[]
29
     */
30
    public function getReasons() : array
31
    {
32
        return $this->reasons;
33
    }
34
35
    public function reason() : Reason
36
    {
37
        return $this->reasons[0];
38
    }
39
40
    public function description() : string
41
    {
42
        $description = '';
43
        foreach($this->reasons as $reason) {
44
            $description .= $reason->description() . PHP_EOL;
45
        }
46
47
        return $description;
48
    }
49
50
    public function code() : int
51
    {
52
        return 0;
53
    }
54
}
55