Sequenzia/lib/Rails/SystemExit/SystemExit.php
2013-10-26 10:53:37 -05:00

33 lines
655 B
PHP
Executable File

<?php
namespace Rails\SystemExit;
class SystemExit
{
protected $callbacks = [];
public function register(callable $callback, $name = '')
{
if ($name)
$this->callbacks[$name] = $callback;
else
$this->callbacks[] = $callback;
}
public function unregister($name)
{
if (isset($this->callbacks[$name])) {
unset($this->callbacks[$name]);
return true;
} else {
return false;
}
}
public function run()
{
foreach ($this->callbacks as $callback) {
call_user_func($callback);
}
}
}