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

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

Returns all messages for given type.
public get ( $type ) : Krucas\Notification\Collection
$type
Результат Krucas\Notification\Collection
    public function get($type)
    {
        $collection = new Collection();
        foreach ($this->notifications as $key => $message) {
            if ($message->getType() == $type) {
                $collection->add($message);
            }
        }
        return $collection;
    }

Usage Example

 /**
  * @depends testGetErrorMessageContainer
  */
 public function testGetFirstMessageFromContainer(\Krucas\Notification\NotificationsBag $bag)
 {
     $this->assertInstanceOf('Krucas\\Notification\\Message', $bag->get('error')->first());
     $this->assertEquals('test error', $bag->get('error')->first()->getMessage());
     $this->assertEquals('error', $bag->get('error')->first()->getType());
     $this->assertEquals(':message!', $bag->get('error')->first()->getFormat());
     return $bag;
 }