/**
* Method to evaluate the validator
*
* @param mixed $input
* @throws Exception
* @return boolean
*/
public function evaluate($input = null)
{
// Check to make sure the input is a valid Ipv4 address.
$ip = new Ipv4();
if (!Ipv4::factory()->evaluate($input)) {
throw new Exception('The IP address must be a valid IPv4 address.');
}
// Set the input, if passed
if (null !== $input) {
$this->input = $input;
}
// Set the default message
if (null === $this->defaultMessage) {
if ($this->condition) {
$this->defaultMessage = I18n::factory()->__('The value must be part of the subnet %1.', $this->value);
} else {
$this->defaultMessage = I18n::factory()->__('The value must not be part of the subnet %1.', $this->value);
}
}
// Evaluate the input against the validator
if ((substr($this->input, 0, strrpos($this->input, '.')) == $this->value) == $this->condition) {
$this->result = true;
} else {
$this->result = false;
}
return $this->result;
}