Created
July 21, 2015 13:48
-
-
Save G4MR/4bad89474cff4c280d0d to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
namespace Component | |
{ | |
/** | |
* Class Middleware | |
* @package Component | |
*/ | |
class Middleware | |
{ | |
protected static $callable_array = []; | |
/** | |
* @param string | |
* @param callable | |
* @return boolean | |
*/ | |
public function register($name, $callable = null) | |
{ | |
if(is_callable($callable)) { | |
static::$callable_array[$name] = $callable; | |
return true; | |
} | |
return false; | |
} | |
/** | |
* @param string | |
* @return callable|boolean | |
*/ | |
public function get($name) | |
{ | |
if(isset(static::$callable_array[$name])) { | |
return static::$callable_array[$name]; | |
} | |
return false; | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment