Conditions | 4 |
Paths | 4 |
Total Lines | 14 |
Code Lines | 7 |
Lines | 0 |
Ratio | 0 % |
Tests | 9 |
CRAP Score | 4 |
Changes | 0 |
1 | <?php |
||
30 | 21 | public function __construct(string $email, ?string $name = null) |
|
31 | { |
||
32 | 21 | if (! self::isValidEmail($email)) { |
|
33 | 1 | throw new InvalidArgumentException("invalid e-mail address"); |
|
34 | } |
||
35 | |||
36 | 20 | if (! empty($name)) { |
|
37 | 12 | if (preg_match('/[\r\n]/', $name)) { |
|
38 | 1 | throw new RuntimeException("CR/LF injection detected"); |
|
39 | } |
||
40 | 11 | } |
|
41 | |||
42 | 19 | $this->email = $email; |
|
43 | 19 | $this->name = $name; |
|
44 | 19 | } |
|
61 |