Created
February 19, 2014 15:21
-
-
Save sukei/9094158 to your computer and use it in GitHub Desktop.
A Router in a Tweet
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 | |
/** | |
* The Router class is a fast and lightweight router (yes it is). It can handle | |
* a path and call the matching controller. If there is no match, then an | |
* exception will be throwned. | |
* | |
* ...and it fits in a tweet. | |
* | |
* @author Quentin Schuler aka Sukei <[email protected]> | |
*/ | |
class Router{private $r;function add($r,$c){$this->r[$r]=$c;}function match($r){$r=@$this->r[$r]?:function(){throw new Exception;};$r();}} |
Author
sukei
commented
Feb 19, 2014
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment