Conditions | 3 |
Paths | 1 |
Total Lines | 21 |
Code Lines | 13 |
Lines | 0 |
Ratio | 0 % |
Tests | 0 |
CRAP Score | 12 |
Changes | 0 |
1 | <?php |
||
65 | final public static function fromArray(array $array): AbstractRecipient |
||
66 | { |
||
67 | return new static( |
||
68 | new AddressList( |
||
69 | array_map( |
||
70 | function (array $pair) { |
||
71 | $count = count($pair); |
||
72 | if ($count !== 1 && $count !== 2) { |
||
73 | throw new \InvalidArgumentException('Each recipient should have one or two elements: [<EmailAddress>] or [<EmailAddress>, <Name>]'); |
||
74 | } |
||
75 | [$emailAddress, $name] = $pair + [1 => '']; |
||
76 | return new Address( |
||
77 | new EmailAddress($emailAddress), |
||
78 | $name |
||
79 | ); |
||
80 | }, |
||
81 | $array |
||
82 | ) |
||
83 | ) |
||
84 | ); |
||
85 | } |
||
86 | } |
This check marks access to variables or properties that have not been declared yet. While PHP has no explicit notion of declaring a variable, accessing it before a value is assigned to it is most likely a bug.