public function append($message, $severity = Error::SEVERITY_ERROR, $code = null)
{
switch ($severity) {
case Error::SEVERITY_ERROR:
$notification = new Error($message, $code);
break;
case Error::SEVERITY_WARNING:
$notification = new Warning($message, $code);
break;
case Error::SEVERITY_NOTICE:
$notification = new Notice($message, $code);
break;
case Error::SEVERITY_OK:
$notification = new Message($message, $code);
break;
default:
throw new Exception('Invalid severity', 1455819761);
}
$this->messages->attach($notification);
}