stringify() публичный статический Метод

public static stringify ( mixed $value, integer $depth = 1 ) : string
$value mixed
$depth integer
Результат string
Пример #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);
 }
Пример #2
0
 public function __construct($dividend)
 {
     if (!is_numeric($dividend) || (int) $dividend != $dividend) {
         $message = 'Dividend %s must be an integer';
         throw new ComponentException(sprintf($message, ValidationException::stringify($dividend)));
     }
     $this->dividend = (int) $dividend;
 }
Пример #3
0
 public function reportError($input, array $extraParams = array())
 {
     $exception = $this->createException();
     $name = $this->name ?: ValidationException::stringify($input);
     $params = array_merge(get_class_vars(__CLASS__), get_object_vars($this), $extraParams, compact('input'));
     $exception->configure($name, $params);
     if (!is_null($this->template)) {
         $exception->setTemplate($this->template);
     }
     return $exception;
 }
Пример #4
0
 public static function format($template, array $vars = [])
 {
     return preg_replace_callback('/{{(\\w+)}}/', function ($match) use($vars) {
         if (!isset($vars[$match[1]])) {
             return $match[0];
         }
         $value = $vars[$match[1]];
         if ('name' == $match[1]) {
             return $value;
         }
         return ValidationException::stringify($value);
     }, $template);
 }
 /**
  * @dataProvider providerForStringify
  */
 public function testStringifyShouldConvertStringsProperly($input, $result)
 {
     $this->assertStringMatchesFormat($result, ValidationException::stringify($input));
 }