IpTest   A
last analyzed

Complexity

Total Complexity 5

Size/Duplication

Total Lines 39
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 9
c 1
b 0
f 0
dl 0
loc 39
ccs 11
cts 11
cp 1
rs 10
wmc 5

3 Methods

Rating   Name   Duplication   Size   Complexity  
A ip4test() 0 6 2
A setInput() 0 3 1
A ip6test() 0 6 2
1
<?php
2
namespace Lioo19\Models;
3
4
/**
5
 * Class for checking IP-adress to ip4 and ip6 standard.
6
 * Class only contain methods for checking
7
 *
8
 */
9
class IpTest
10
{
11
    /**
12
    * @var string $ipinput   userinputted ip
13
    */
14
    private $ipinput;
15
16
    /**
17
     * Function to set user ip
18
     *
19
     * @param null|string    $ipinp  User input
20
     */
21 9
    public function setInput(string $ipinp = "")
22
    {
23 9
        $this->ipinput = $ipinp;
24 9
    }
25
26
    /**
27
    * method for checking Ip4
28
    * @return bool if valid, return true
29
    */
30 8
    public function ip4test()
31
    {
32 8
        if (filter_var($this->ipinput, FILTER_VALIDATE_IP, FILTER_FLAG_IPV4)) {
33 6
            return true;
34
        }
35 5
        return false;
36
    }
37
38
    /**
39
    * method for checking Ip6
40
    * @return bool if valid, return true
41
    */
42 8
    public function ip6test()
43
    {
44 8
        if (filter_var($this->ipinput, FILTER_VALIDATE_IP, FILTER_FLAG_IPV6)) {
45 1
            return true;
46
        }
47 7
        return false;
48
    }
49
}
50