public function getMessages($severity = null)
    {
        if ($severity === null) {
            return $this->messages;
        }

        $messages = [];
        foreach ($this->messages as $message) {
            if ($message->getSeverity() === $severity) {
                $messages[] = $message;
            }
        }
        return $messages;
    }