protected function formatMessage(array $data, $type)
    {
        $shouldBeSticky = $this->config('sticky') === true || $data['dismissable'] !== true;

        $templateData = [
            '{message.baseClass}' => $this->config('baseClass'),
            '{message.class}'     => $this->config('types')[$type],
            '{message.fadeClass}' => $this->config('fadeOut') ? 'fade in' : null,
            '{message.contents}'  => $data['message'],
            '{message.title}'     => null,
            '{button}'            => $shouldBeSticky ? null : $this->config('button')
        ];

        if ($data['dismissable'] === true) {
            $templateData['{message.class}'] .=  ' ' . $this->config('dismissableClass');
        }

        if (! is_null($title = $data['title'])) {
            $templateData['{message.title}'] = sprintf($this->config('title'), $title);
        }

        return str_replace(
            array_keys($templateData), array_values($templateData), $this->config('wrapper')
        );
    }