Krucas\Notification\NotificationsBag::setFormat PHP Method

setFormat() public method

Set format for a given type.
public setFormat ( $type, $format ) : NotificationsBag
$type
$format
return NotificationsBag
    public function setFormat($type, $format)
    {
        if ($this->typeIsAvailable($type)) {
            $this->formats[$type] = $format;
        }
        return $this;
    }

Usage Example

 /**
  * @depends testGetFirstMessageFromContainer
  */
 public function testOverrideMessageFormat(\Krucas\Notification\NotificationsBag $bag)
 {
     $this->assertEquals('<div class="alert alert-:type">:message</div>', $bag->getFormat());
     $bag->setFormat(':message');
     $this->assertEquals(':message', $bag->getFormat());
     $bag->setFormat(':message!', 'error');
     $this->assertEquals(':message!', $bag->getFormat('error'));
     $this->assertEquals(':message', $bag->getFormat());
     return $bag;
 }