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

stringify() public static method

public static stringify ( mixed $value, integer $depth = 1 ) : string
$value mixed
$depth integer
return string
    public static function stringify($value, $depth = 1)
    {
        if ($depth >= self::$maxDepthStringify) {
            return self::$maxReplacementStringify;
        }
        if (is_array($value)) {
            return static::stringifyArray($value, $depth);
        }
        if (is_object($value)) {
            return static::stringifyObject($value, $depth);
        }
        if (is_resource($value)) {
            return sprintf('`[resource] (%s)`', get_resource_type($value));
        }
        if (is_float($value)) {
            if (is_infinite($value)) {
                return ($value > 0 ? '' : '-') . 'INF';
            }
            if (is_nan($value)) {
                return 'NaN';
            }
        }
        return @json_encode($value, JSON_UNESCAPED_SLASHES | JSON_UNESCAPED_UNICODE) ?: $value;
    }

Usage Example

Example #1
0
 /**
  * @dataProvider providerForInvalidFactorDividend
  */
 public function testInvalidDividentShouldThrowComponentException($dividend, $input)
 {
     $this->setExpectedException('Respect\\Validation\\Exceptions\\ComponentException', 'Dividend ' . ValidationException::stringify($dividend) . ' must be an integer');
     // It is enough to simply create a new Factor to trigger the dividend
     // exceptions in __construct.
     new Factor($dividend);
 }
All Usage Examples Of Respect\Validation\Exceptions\ValidationException::stringify