src/Translator.php
public function getMessages(string $key, array $errors = []): array
    {
        // when there is a template for the given key, return only this message.
        if (array_key_exists($key, $this->templates)) {

            return [$this->translate($this->templates[$key], ['attribute' => $key])];

        }

        // return one message for each rule which failed.
        return array_reduce($errors, function ($messages, $error) use ($key) {

            $rule = $error->getRule();
            $parameters = $error->getParameters();

            $template = $this->getTemplate($key, $rule);

            $message = $this->translate($template, array_merge($parameters, [
                'attribute' => $key,
            ]));

            return array_merge($messages, [$message]);

        }, []);
    }
public function getMessages(string $key, array $errors = []): array
    {
        // when there is a template for the given key, return only this message.
        if (array_key_exists($key, $this->templates)) {

            return [$this->translate($this->templates[$key], ['attribute' => $key])];

        }

        // return one message for each rule which failed.
        return array_reduce($errors, function ($messages, $error) use ($key) {

            $rule = $error->getRule();
            $parameters = $error->getParameters();

            $template = $this->getTemplate($key, $rule);

            $message = $this->translate($template, array_merge($parameters, [
                'attribute' => $key,
            ]));

            return array_merge($messages, [$message]);

        }, []);
    }
public function getMessages ( string $ key , array $ errors = [ ] ) : array { // when there is a template for the given key, return only this message. if ( array_key_exists ( $ key , $ this -> templates ) ) { return [ $ this -> translate ( $ this -> templates [ $ key ] , [ 'attribute' => $ key ] ) ] ; } // return one message for each rule which failed. return array_reduce ( $ errors , function ( $ messages , $ error ) use ( $ key ) { $ rule = $ error -> getRule ( ) ; $ parameters = $ error -> getParameters ( ) ; $ template = $ this -> getTemplate ( $ key , $ rule ) ; $ message = $ this -> translate ( $ template , array_merge ( $ parameters , [ 'attribute' => $ key , ] ) ) ; return array_merge ( $ messages , [ $ message ] ) ; } , [ ] ) ; }
Return a list of messages from a rule key and its list of errors.

@param string    $key
@param array     $errors
@return array
Return a list of messages from a rule key and its list of errors .