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

Type::getName()   A

Complexity

Conditions 3
Paths 3

Size

Total Lines 9
Code Lines 7

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 6
CRAP Score 3

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 3
eloc 7
nc 3
nop 1
dl 0
loc 9
ccs 6
cts 6
cp 1
crap 3
rs 10
c 1
b 0
f 0
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