src/Validation.php
private function formatField($value, array $args = []) {
        if ($value === null) {
            $r = $this->translate('null');
        } elseif ($value === true) {
            $r = $this->translate('true');
        } elseif ($value === false) {
            $r = $this->translate('false');
        } elseif (is_string($value)) {
            $r = $this->translate($value);
        } elseif (is_numeric($value)) {
            $r = $value;
        } elseif (is_array($value)) {
            $argArray = array_map([$this, 'formatField'], $value);
            $r = implode(', ', $argArray);
        } elseif ($value instanceof \DateTimeInterface) {
            $r = $value->format('c');
        } else {
            $r = $value;
        }

        $format = array_shift($args);
        switch ($format) {
            case 'plural':
                $singular = array_shift($args);
                $plural = array_shift($args) ?: $singular.'s';
                $count = is_array($value) ? count($value) : $value;
                $r = $count == 1 ? $singular : $plural;
                break;
        }

        return (string)$r;
    }
private function formatField($value, array $args = []) {
        if ($value === null) {
            $r = $this->translate('null');
        } elseif ($value === true) {
            $r = $this->translate('true');
        } elseif ($value === false) {
            $r = $this->translate('false');
        } elseif (is_string($value)) {
            $r = $this->translate($value);
        } elseif (is_numeric($value)) {
            $r = $value;
        } elseif (is_array($value)) {
            $argArray = array_map([$this, 'formatField'], $value);
            $r = implode(', ', $argArray);
        } elseif ($value instanceof \DateTimeInterface) {
            $r = $value->format('c');
        } else {
            $r = $value;
        }

        $format = array_shift($args);
        switch ($format) {
            case 'plural':
                $singular = array_shift($args);
                $plural = array_shift($args) ?: $singular.'s';
                $count = is_array($value) ? count($value) : $value;
                $r = $count == 1 ? $singular : $plural;
                break;
        }

        return (string)$r;
    }
private function formatField ( $ value , array $ args = [ ] ) { if ( $ value === null ) { $ r = $ this -> translate ( 'null' ) ; } elseif ( $ value === true ) { $ r = $ this -> translate ( 'true' ) ; } elseif ( $ value === false ) { $ r = $ this -> translate ( 'false' ) ; } elseif ( is_string ( $ value ) ) { $ r = $ this -> translate ( $ value ) ; } elseif ( is_numeric ( $ value ) ) { $ r = $ value ; } elseif ( is_array ( $ value ) ) { $ argArray = array_map ( [ $ this , 'formatField' ] , $ value ) ; $ r = implode ( ', ' , $ argArray ) ; } elseif ( $ value instanceof \ DateTimeInterface ) { $ r = $ value -> format ( 'c' ) ; } else { $ r = $ value ; } $ format = array_shift ( $ args ) ; switch ( $ format ) { case 'plural' : $ singular = array_shift ( $ args ) ; $ plural = array_shift ( $ args ) ? : $ singular . 's' ; $ count = is_array ( $ value ) ? count ( $ value ) : $ value ; $ r = $ count == 1 ? $ singular : $ plural ; break ; } return ( string ) $ r ; }
Translate an argument being placed in an error message.

@param mixed $value The argument to translate.
@param array $args Formatting arguments.
@return string Returns the translated string.
Translate an argument being placed in an error message .