This repository has been archived on 2024-10-25. You can view files and clone it, but cannot push or open issues or pull requests.
Sequenzia/lib/Rails/SystemExit/SystemExit.php
2013-10-02 11:14:53 -05:00

32 lines
653 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);
}
}
}