Skip to content

Instantly share code, notes, and snippets.

@G4MR
Created July 21, 2015 13:48
Show Gist options
  • Save G4MR/4bad89474cff4c280d0d to your computer and use it in GitHub Desktop.
Save G4MR/4bad89474cff4c280d0d to your computer and use it in GitHub Desktop.
<?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