Passed
Branch main (86ec0c)
by Michele
08:09
created

Type   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 34
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 2
Bugs 0 Features 0
Metric Value
eloc 10
dl 0
loc 34
ccs 6
cts 6
cp 1
rs 10
c 2
b 0
f 0
wmc 3

1 Method

Rating   Name   Duplication   Size   Complexity  
A getName() 0 9 3
1
<?php
2
3
namespace IPLib\Address;
4
5
/**
6
 * Types of IP addresses.
7
 */
8
class Type
9
{
10
    /**
11
     * IPv4 address.
12
     *
13
     * @var int
14
     */
15
    const T_IPv4 = 4;
16
17
    /**
18
     * IPv6 address.
19
     *
20
     * @var int
21
     */
22
    const T_IPv6 = 6;
23
24
    /**
25
     * Get the name of a type.
26
     *
27
     * @param int $type
28
     *
29
     * @return string
30
     *
31
     * @since 1.1.0
32
     */
33 214
    public static function getName($type)
34
    {
35
        switch ($type) {
36 214
            case static::T_IPv4:
37 152
                return 'IP v4';
38 62
            case static::T_IPv6:
39 59
                return 'IP v6';
40
            default:
41 3
                return sprintf('Unknown type (%s)', $type);
42
        }
43
    }
44
}
45