public function guessId()
{
if (!empty($this->id) && $this->id != 'validation') {
return $this->id;
}
$pieces = explode('\\', get_called_class());
$exceptionClassShortName = end($pieces);
$ruleClassShortName = str_replace('Exception', '', $exceptionClassShortName);
$ruleName = lcfirst($ruleClassShortName);
return $ruleName;
}
/** * @param string $path * @param ValidationException $exception * * @return ValidationException */ private function getExceptionForPath($path, ValidationException $exception) { if ($path === $exception->guessId()) { return $exception; } if (!$exception instanceof self) { return $exception; } foreach ($exception as $subException) { return $subException; } return $exception; }