54 \Erebot\Interfaces\Event\Match $filter = null
56 $this->setCallback($callback);
57 $this->setFilter($filter);
65 public function setCallback(callable $callback)
67 $this->callback = $callback;
71 public function getCallback()
73 return $this->callback;
76 public function setFilter(\Erebot\Interfaces\Event\Match $filter = null)
78 $this->filter = $filter;
82 public function getFilter()
87 public function handleEvent(\Erebot\Interfaces\Event\Base\Generic $event)
91 if ($this->filter !== null) {
92 $matched = $this->filter->match($event);
95 $cb = $this->callback;
96 return ($matched ? $cb($this, $event) : null);
__construct(callable $callback,\Erebot\Interfaces\Event\Match $filter=null)
$callback
Callable object to use when this handler is triggered.
An event handler which will call a callback function/method whenever a set of conditions are met...
$filter
Filtering object to decide whether the callback must be called or not.