You are here

public function ConstraintViolation::__toString in Zircon Profile 8

Same name and namespace in other branches
  1. 8.0 vendor/symfony/validator/ConstraintViolation.php \Symfony\Component\Validator\ConstraintViolation::__toString()

Converts the violation into a string for debugging purposes.

Return value

string The violation as string.

File

vendor/symfony/validator/ConstraintViolation.php, line 110

Class

ConstraintViolation
Default implementation of {@ConstraintViolationInterface}.

Namespace

Symfony\Component\Validator

Code

public function __toString() {
  if (is_object($this->root)) {
    $class = 'Object(' . get_class($this->root) . ')';
  }
  elseif (is_array($this->root)) {
    $class = 'Array';
  }
  else {
    $class = (string) $this->root;
  }
  $propertyPath = (string) $this->propertyPath;
  $code = $this->code;
  if ('' !== $propertyPath && '[' !== $propertyPath[0] && '' !== $class) {
    $class .= '.';
  }
  if (!empty($code)) {
    $code = ' (code ' . $code . ')';
  }
  return $class . $propertyPath . ":\n    " . $this
    ->getMessage() . $code;
}