protected function createMessage($message, $variables = null)
    {
        if (null !== $variables && is_array($variables)) {
            $variables = array_merge($this->getMessageVariables(), $variables);
        } else {
            $variables = $this->getMessageVariables();
        }

        foreach ($variables as $variableKey => $variable) {
            if (is_array($variable) || ($variable instanceof Traversable)) {
                $variable = implode(', ', array_values($variable));
            }

            if (!is_scalar($variable)) {
                $variable = $this->switchType($variable);
            }

            $message = str_replace("%$variableKey%", (string) $variable, $message);
        }

        return $message;
    }