for testing and deploying your application
for finding and fixing issues
for empowering human code reviews
<?php
namespace Safelist\Definition;
use IpUtils\Expression\ExpressionInterface;
/**
* Represents a CIDR notation
*
* @author Sam Stenvall <[email protected]>
* @copyright Copyright © Sam Stenvall 2014-
* @license http://www.opensource.org/licenses/bsd-license.php New BSD License
*/
abstract class IPCIDR extends Definition
{
* @var ExpressionInterface
protected $_subnet;
public function validate()
try
$this->_subnet = \IpUtils\Factory::getExpression($this->_definition);
// Check that we got a subnet expression and not something else
if (!$this->_subnet instanceof \IpUtils\Expression\Subnet)
return false;
}
catch (\Exception $e)
unset($e);
return true;
public function match($value)
$address = \IpUtils\Factory::getAddress($value);
return $this->_subnet->matches($address);