function ConstraintViolation::__toString
Overrides ConstraintViolationInterface::__toString
File
-
vendor/
symfony/ validator/ ConstraintViolation.php, line 55
Class
- ConstraintViolation
- Default implementation of {@ConstraintViolationInterface}.
Namespace
Symfony\Component\ValidatorCode
public function __toString() : string {
if (\is_object($this->root)) {
$class = 'Object(' . $this->root::class . ')';
}
elseif (\is_array($this->root)) {
$class = 'Array';
}
else {
$class = (string) $this->root;
}
$propertyPath = (string) $this->propertyPath;
if ('' !== $propertyPath && '[' !== $propertyPath[0] && '' !== $class) {
$class .= '.';
}
if (null !== ($code = $this->code) && '' !== $code) {
$code = ' (code ' . $code . ')';
}
return $class . $propertyPath . ":\n " . $this->getMessage() . $code;
}