| Conditions | 3 |
| Paths | 1 |
| Total Lines | 21 |
| Code Lines | 13 |
| Lines | 0 |
| Ratio | 0 % |
| Tests | 13 |
| CRAP Score | 3 |
| Changes | 0 | ||
| 1 | <?php |
||
| 65 | 2 | final public static function fromArray(array $array): AbstractRecipient |
|
| 66 | { |
||
| 67 | 2 | return new static( |
|
| 68 | 2 | new AddressList( |
|
| 69 | 2 | array_map( |
|
| 70 | 2 | function (array $pair) { |
|
| 71 | 2 | $count = count($pair); |
|
| 72 | 2 | if ($count !== 1 && $count !== 2) { |
|
| 73 | 1 | throw new \InvalidArgumentException('Each recipient should have one or two elements: [<EmailAddress>] or [<EmailAddress>, <Name>]'); |
|
| 74 | } |
||
| 75 | 2 | [$emailAddress, $name] = $pair + [1 => '']; |
|
| 76 | 2 | return new Address( |
|
| 77 | 2 | new EmailAddress($emailAddress), |
|
| 78 | 2 | $name |
|
| 79 | ); |
||
| 80 | 2 | }, |
|
| 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.