for testing and deploying your application
for finding and fixing issues
for empowering human code reviews
<?php
namespace nstdio\notymo;
use Closure;
use nstdio\notymo\exception\PushNotificationException;
/**
* Class CallbackInvoker
*
* @package nstdio\notymo
* @author Edgar Asatryan <[email protected]>
*/
class CallbackInvoker implements LifeCycleCallback, LifeCycleCallbackInvoker
{
* @var Closure
protected $onComplete;
protected $onEachSent;
protected $onError;
* @inheritdoc
public function callOnComplete(MessageQueue $param)
if (isset($this->onComplete)) {
call_user_func_array($this->onComplete, array($param));
}
public function callOnEachSent(MessageInterface $message, $feedBack = null)
if (isset($this->onEachSent)) {
call_user_func_array($this->onEachSent, array($message, $feedBack));
public function callOnError(MessageInterface $message, PushNotificationException $exc)
if (isset($this->onError)) {
call_user_func_array($this->onError, array($message, $exc));
} else {
throw $exc;
public function onComplete(\Closure $callback)
$this->onComplete = $callback;
public function onEachSent(\Closure $callback)
$this->onEachSent = $callback;
public function onError(Closure $callback)
$this->onError = $callback;
public function detach()
unset($this->onComplete, $this->onEachSent, $this->onError);