Krucas\Notification\NotificationsBag::add PHP Метод

add() публичный Метод

If message is array, adds multiple messages. Message can be string, array (array can contain string for message, or array of message and format). Flashes flashable messages.
public add ( $type, string | Krucas\Notification\Message | Closure $message, boolean $flash = true, null $format = null ) : NotificationsBag
$type
$message string | Krucas\Notification\Message | Closure
$flash boolean
$format null
Результат NotificationsBag
    public function add($type, $message, $flash = true, $format = null)
    {
        if (!$this->typeIsAvailable($type)) {
            return $this;
        }
        if ($message instanceof \Krucas\Notification\Message) {
            $m = $message;
            $this->addInstance($m, $type, $flash, $format);
        } elseif ($message instanceof Closure) {
            $m = new Message($type, null, $flash, $format);
            call_user_func_array($message, [$m]);
            $this->addInstance($m, $type, $flash, $format);
        } else {
            $m = new Message($type, $message, $flash, $this->checkFormat($format, $type));
        }
        if (!$m->isFlash()) {
            $this->notifications->add($m);
            $this->fireEvent('added', $m);
        } else {
            $this->fireEvent('flash', $m);
        }
        return $this;
    }