Conditions | 5 |
Paths | 4 |
Total Lines | 16 |
Code Lines | 8 |
Lines | 0 |
Ratio | 0 % |
Changes | 0 |
1 | <?php |
||
29 | public static function is_valid($gender = null) |
||
30 | { |
||
31 | if (is_null($gender)) { |
||
32 | throw new \InvalidArgumentException('Please enter a valid gender.'); |
||
33 | } |
||
34 | |||
35 | if (empty($gender) || strlen($gender) > 1) { |
||
36 | return false; |
||
37 | } |
||
38 | |||
39 | if (is_numeric($gender)) { |
||
40 | return false; |
||
41 | } |
||
42 | |||
43 | return in_array($gender, ['f', 'm']); |
||
44 | } |
||
45 | } |
||
46 |