IpValidate::validate()   A
last analyzed

Complexity

Conditions 2
Paths 2

Size

Total Lines 6
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 4
CRAP Score 2

Importance

Changes 0
Metric Value
eloc 3
dl 0
loc 6
ccs 4
cts 4
cp 1
rs 10
c 0
b 0
f 0
cc 2
nc 2
nop 1
crap 2
1
<?php
2
3
namespace KW\Models;
4
5
use Anax\Commons\ContainerInjectableInterface;
6
use Anax\Commons\ContainerInjectableTrait;
7
8
/**
9
 * Verfies wether an ip address is valid or not
10
 *
11
 */
12
13
class IpValidate implements ContainerInjectableInterface
14
{
15
    use ContainerInjectableTrait;
16
17
18
    /**
19
     * Verify an ip-adress is valid
20
     *
21
     * @param string $ipnumber to verify
22
     *
23
     * @return boolean
24
     */
25 5
    public function validate(string $ipnumber)
26
    {
27 5
        if (!filter_var($ipnumber, FILTER_VALIDATE_IP)) {
28 2
            return false;
29
        }
30 3
        return true;
31
    }
32
}
33