| Total Complexity | 7 |
| Total Lines | 52 |
| Duplicated Lines | 0 % |
| Coverage | 100% |
| Changes | 1 | ||
| Bugs | 0 | Features | 0 |
| 1 | <?php |
||
| 5 | class ValidateIp |
||
| 6 | { |
||
| 7 | |||
| 8 | /** |
||
| 9 | * This is the index method action, it handles: |
||
| 10 | * IP validation of the queryparameter ip. |
||
| 11 | * |
||
| 12 | * @return bool |
||
| 13 | */ |
||
| 14 | 19 | public function validate(string $ipAdr = null) : bool |
|
| 15 | { |
||
| 16 | 19 | if ($ipAdr) { |
|
| 17 | 17 | if (filter_var($ipAdr, FILTER_VALIDATE_IP)) { |
|
| 18 | 7 | return true; |
|
| 19 | } else { |
||
| 20 | 10 | return false; |
|
| 21 | } |
||
| 22 | } else { |
||
| 23 | 2 | return false; |
|
| 24 | } |
||
| 25 | } |
||
| 26 | |||
| 27 | |||
| 28 | /** |
||
| 29 | * This is the index method action, it handles: |
||
| 30 | * IP validation of the queryparameter ip. |
||
| 31 | * |
||
| 32 | * @return string|void $type |
||
| 33 | */ |
||
| 34 | 6 | public function getIpType(string $ipAdr) |
|
| 45 | } |
||
| 46 | |||
| 47 | /** |
||
| 48 | * This is the index method action, it handles: |
||
| 49 | * IP validation of the queryparameter ip. |
||
| 50 | * |
||
| 51 | * @return string $host |
||
| 52 | */ |
||
| 53 | 4 | public function getHostName(string $ipAdr) : string |
|
| 57 | } |
||
| 58 | } |
||
| 59 |