IPAddress::match()   A
last analyzed

Complexity

Conditions 2
Paths 4

Size

Total Lines 11
Code Lines 8

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 2
eloc 8
c 1
b 0
f 0
nc 4
nop 1
dl 0
loc 11
rs 10
1
<?php
2
3
namespace Whitelist\Definition;
4
5
use Exception;
6
use IpUtils\Factory;
7
8
/**
9
 * Represents an IP address definition
10
 *
11
 * @author Sam Stenvall <[email protected]>
12
 * @copyright Copyright &copy; Sam Stenvall 2014-
13
 * @license http://www.opensource.org/licenses/bsd-license.php New BSD License
14
 */
15
abstract class IPAddress extends Definition
16
{
17
18
    public function match($value)
19
    {
20
        try {
21
            $address = Factory::getAddress($this->_definition);
22
            $otherAddress = Factory::getExpression($value);
23
24
            return $address->matches($otherAddress);
25
        } catch (Exception $e) {
26
            unset($e);
27
28
            return false;
29
        }
30
    }
31
32
}
33