Respect\Validation\Exceptions\ValidationException::stringifyObject PHP Method

stringifyObject() public static method

public static stringifyObject ( mixed $value, integer $depth = 2 ) : string
$value mixed
$depth integer
return string
    public static function stringifyObject($value, $depth = 2)
    {
        $nextDepth = $depth + 1;
        if ($value instanceof DateTime) {
            return sprintf('"%s"', $value->format('Y-m-d H:i:s'));
        }
        $class = get_class($value);
        if ($value instanceof Traversable) {
            return sprintf('`[traversable] (%s: %s)`', $class, static::stringify(iterator_to_array($value), $nextDepth));
        }
        if ($value instanceof Exception) {
            $properties = ['message' => $value->getMessage(), 'code' => $value->getCode(), 'file' => $value->getFile() . ':' . $value->getLine()];
            return sprintf('`[exception] (%s: %s)`', $class, static::stringify($properties, $nextDepth));
        }
        if (method_exists($value, '__toString')) {
            return static::stringify($value->__toString(), $nextDepth);
        }
        $properties = static::stringify(get_object_vars($value), $nextDepth);
        return sprintf('`[object] (%s: %s)`', $class, str_replace('`', '', $properties));
    }