Completed
Pull Request — master (#10)
by
unknown
01:00
created

IPAddress::match()   A

Complexity

Conditions 2
Paths 4

Size

Total Lines 14

Duplication

Lines 0
Ratio 0 %

Importance

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