Localhost   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 26
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 1

Test Coverage

Coverage 100%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 2
lcom 0
cbo 1
dl 0
loc 26
ccs 4
cts 4
cp 1
rs 10
c 1
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A isValid() 0 4 1
A convert() 0 4 1
1
<?php
2
/**
3
 * IP range converter for a localhost loopback address
4
 *
5
 * PHP version 5.5
6
 *
7
 * @category   OpCacheGUI
8
 * @package    Network
9
 * @subpackage Ip
10
 * @author     Pieter Hordijk <[email protected]>
11
 * @copyright  Copyright (c) 2014 Pieter Hordijk <https://github.com/PeeHaa>
12
 * @license    http://www.opensource.org/licenses/mit-license.html  MIT License
13
 * @version    1.0.0
14
 */
15
namespace OpCacheGUI\Network\Ip;
16
17
/**
18
 * IP range converter for a localhost loopback address
19
 *
20
 * @category   OpCacheGUI
21
 * @package    Network
22
 * @subpackage Ip
23
 * @author     Pieter Hordijk <[email protected]>
24
 */
25
class Localhost extends Single
26
{
27
    /**
28
     * Checks whether is certain address is valid for the converter implementation
29
     *
30
     * @param string $address The address to check
31
     *
32
     * @return boolean True when the address is valid
33
     */
34 5
    public function isValid($address)
35
    {
36 5
        return $address === 'localhost';
37
    }
38
39
    /**
40
     * Converts an IP address or range into a range to easily check for access
41
     *
42
     * @param string $address The IP address / range
43
     *
44
     * @return double[] Array containing the first and last ip in the range
45
     */
46 1
    public function convert($address)
47
    {
48 1
        return parent::convert('127.0.0.1');
49
    }
50
}
51