Subversion-Projekte lars-tiefland.laravel_shop

Revision

Details | Letzte Änderung | Log anzeigen | RSS feed

Revision Autor Zeilennr. Zeile
148 lars 1
<?php
2
 
3
namespace Egulias\EmailValidator\Result;
4
 
5
use Egulias\EmailValidator\Result\Reason\EmptyReason;
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) : void
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 0 !== count($this->reasons)
38
            ? current($this->reasons)
39
            : new EmptyReason();
40
    }
41
 
42
    public function description() : string
43
    {
44
        $description = '';
45
        foreach($this->reasons as $reason) {
46
            $description .= $reason->description() . PHP_EOL;
47
        }
48
 
49
        return $description;
50
    }
51
 
52
    public function code() : int
53
    {
54
        return 0;
55
    }
56
}