IpCheck::validateIp()   A
last analyzed

Complexity

Conditions 2
Paths 2

Size

Total Lines 6
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 3
nc 2
nop 1
dl 0
loc 6
c 1
b 0
f 0
cc 2
rs 10
1
<?php
2
3
4
namespace Anax\Controller;
5
6
class IpCheck
7
{
8
9
10
11
    /**
12
13
     * Validate the ip address
14
15
     */
16
17
    public function validateIp($ip)
18
    {
19
        if (filter_var($ip, FILTER_VALIDATE_IP)) {
20
            return true;
21
        }
22
        return false;
23
    }
24
25
26
    /**
27
28
     * Validate domains
29
30
     */
31
32
    public function validateDomain($ip)
33
    {
34
35
        if ($this->validateIp($ip)) {
36
            if ($ip != gethostbyaddr($ip)) {
37
                return gethostbyaddr($ip);
38
            } else {
39
                return "Not found";
40
            }
41
        }
42
        return "Not found";
43
    }
44
}
45