Skip to content

Commit b61850f

Browse files
committed
Merge remote-tracking branch 'origin/master'
2 parents 166b30e + a0856e4 commit b61850f

File tree

1 file changed

+25
-0
lines changed

1 file changed

+25
-0
lines changed

src/Krucas/Notification/NotificationsBag.php

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -607,6 +607,31 @@ public function count()
607607
return count($this->notifications);
608608
}
609609

610+
/**
611+
* Check if a message is set for given type.
612+
*
613+
* @param $type
614+
* @return bool
615+
*/
616+
public function has($type = null)
617+
{
618+
if( $this->count() === 0 )
619+
return false;
620+
621+
if (is_null($type) )
622+
return true;
623+
624+
if( !$this->typeIsAvailable($type) )
625+
return false;
626+
627+
foreach ($this->notifications as $key => $message) {
628+
if ($message->getType() == $type)
629+
return true;
630+
}
631+
632+
return false;
633+
}
634+
610635
/**
611636
* Fire event for a given message.
612637
*

0 commit comments

Comments
 (0)