Exception/Exception.php
public function getMessageWithVariables()
    {
        $message = $this->message;

        preg_match(self::VARIABLE_REGEX, $message, $variables);

        foreach ($variables as $variable) {
            $variableName = substr($variable, 1, -1);

            if (!isset($this->$variableName)) {
                throw new \Exception(sprintf(
                    'Variable "%s" for exception "%s" not found',
                    $variableName,
                    get_class($this)
                ), 500);
            }

            if (!is_string($this->$variableName)) {
                throw new \Exception(sprintf(
                    'Variable "%s" for exception "%s" must be a string, %s found',
                    $variableName,
                    get_class($this),
                    gettype($this->$variableName)
                ), 500);
            }

            $message = str_replace($variable, $this->$variableName, $message);
        }

        return $message;
    }
public function getMessageWithVariables()
    {
        $message = $this->message;

        preg_match(self::VARIABLE_REGEX, $message, $variables);

        foreach ($variables as $variable) {
            $variableName = substr($variable, 1, -1);

            if (!isset($this->$variableName)) {
                throw new \Exception(sprintf(
                    'Variable "%s" for exception "%s" not found',
                    $variableName,
                    get_class($this)
                ), 500);
            }

            if (!is_string($this->$variableName)) {
                throw new \Exception(sprintf(
                    'Variable "%s" for exception "%s" must be a string, %s found',
                    $variableName,
                    get_class($this),
                    gettype($this->$variableName)
                ), 500);
            }

            $message = str_replace($variable, $this->$variableName, $message);
        }

        return $message;
    }
public function getMessageWithVariables ( ) { $ message = $ this -> message ; preg_match ( self :: VARIABLE_REGEX , $ message , $ variables ) ; foreach ( $ variables as $ variable ) { $ variableName = substr ( $ variable , 1 , - 1 ) ; if ( ! isset ( $ this -> $ variableName ) ) { throw new \ Exception ( sprintf ( 'Variable "%s" for exception "%s" not found' , $ variableName , get_class ( $ this ) ) , 500 ) ; } if ( ! is_string ( $ this -> $ variableName ) ) { throw new \ Exception ( sprintf ( 'Variable "%s" for exception "%s" must be a string, %s found' , $ variableName , get_class ( $ this ) , gettype ( $ this -> $ variableName ) ) , 500 ) ; } $ message = str_replace ( $ variable , $ this -> $ variableName , $ message ) ; } return $ message ; }
Get message with variables

@throws \Exception

@return string
Get message with variables