IpValidator::validate()   A
last analyzed

Complexity

Conditions 3
Paths 3

Size

Total Lines 10
Code Lines 6

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 5
CRAP Score 3.0416

Importance

Changes 0
Metric Value
dl 0
loc 10
ccs 5
cts 6
cp 0.8333
rs 9.4285
c 0
b 0
f 0
cc 3
eloc 6
nc 3
nop 1
crap 3.0416
1
<?php namespace Arcanedev\GeoIP\Support;
2
3
/**
4
 * Class     IpValidator
5
 *
6
 * @package  Arcanedev\GeoIP\Support
7
 * @author   ARCANEDEV <[email protected]>
8
 */
9
class IpValidator
10
{
11
    /* -----------------------------------------------------------------
12
     |  Main Methods
13
     | -----------------------------------------------------------------
14
     */
15
16
    /**
17
     * Validate the IP Address.
18
     *
19
     * @param  string  $ipAddress
20
     *
21
     * @return bool
22
     */
23 6
    public static function validate($ipAddress)
24
    {
25 6
        if (filter_var($ipAddress, FILTER_VALIDATE_IP, FILTER_FLAG_IPV4|FILTER_FLAG_NO_PRIV_RANGE|FILTER_FLAG_NO_RES_RANGE))
26 3
            return true;
27
28 3
        if (filter_var($ipAddress, FILTER_VALIDATE_IP, FILTER_FLAG_IPV6|FILTER_FLAG_NO_PRIV_RANGE))
29
            return true;
30
31 3
        return true;
32
    }
33
}
34