| Conditions | 4 |
| Paths | 4 |
| Total Lines | 22 |
| Code Lines | 11 |
| Lines | 0 |
| Ratio | 0 % |
| Tests | 11 |
| CRAP Score | 4 |
| 1 | <?php |
||
| 21 | 1 | public static function validate(string $hostname) : bool |
|
| 22 | { |
||
| 23 | 1 | $hostname = preg_replace('/^\*\./', '', $hostname); // wild card allowed in hostname |
|
| 24 | |||
| 25 | 1 | if(in_array($hostname, ['@', '*', '.'])) { |
|
| 26 | 1 | return true; |
|
| 27 | } |
||
| 28 | |||
| 29 | 1 | $hostnameValidation = HostnameValidator::validate($hostname); |
|
| 30 | |||
| 31 | 1 | if ($hostnameValidation) { |
|
| 32 | 1 | return true; |
|
| 33 | } |
||
| 34 | |||
| 35 | 1 | $ipValidation = Ip4Validator::validate($hostname); |
|
| 36 | |||
| 37 | 1 | if ($ipValidation) { |
|
| 38 | 1 | return true; |
|
| 39 | } |
||
| 40 | |||
| 41 | 1 | return false; |
|
| 42 | } |
||
| 43 | } |
||
| 44 |