You are here

public function ConstraintViolation::__toString in Plug 7

Converts the violation into a string for debugging purposes.

Return value

string The violation as string.

File

lib/Symfony/validator/Symfony/Component/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;
}