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

MultipleErrors   A

Complexity

Total Complexity 7

Size/Duplication

Total Lines 44
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 2

Test Coverage

Coverage 87.5%

Importance

Changes 0
Metric Value
wmc 7
lcom 1
cbo 2
dl 0
loc 44
ccs 14
cts 16
cp 0.875
rs 10
c 0
b 0
f 0

6 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 3 1
A addReason() 0 4 1
A getReasons() 0 4 1
A code() 0 4 1
A reason() 0 4 1
A description() 0 9 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