| Conditions | 5 |
| Paths | 3 |
| Total Lines | 16 |
| Code Lines | 9 |
| Lines | 0 |
| Ratio | 0 % |
| Tests | 8 |
| CRAP Score | 5.0342 |
| Changes | 0 | ||
| 1 | <?php |
||
| 47 | 8 | public function validate($input): bool |
|
| 48 | { |
||
| 49 | 8 | $input = (string)$input; |
|
| 50 | // check by regular expression |
||
| 51 | 8 | if (preg_match("/^([a-z\d](-*[a-z\d])*)(\.([a-z\d](-*[a-z\d])*))*$/i", $input) |
|
| 52 | 8 | && preg_match("/^.{1,253}$/", $input) |
|
| 53 | 8 | && preg_match("/^[^\.]{1,63}(\.[^\.]{1,63})*$/", $input) |
|
| 54 | ) { |
||
| 55 | // check by DNS record |
||
| 56 | 4 | if ($this->checkDns) { |
|
| 57 | return checkdnsrr($input, 'A'); |
||
| 58 | } |
||
| 59 | 4 | return true; |
|
| 60 | } |
||
| 61 | 4 | return false; |
|
| 62 | } |
||
| 63 | } |
||
| 64 |