Last active
April 20, 2022 08:44
-
-
Save sukei/9093311 to your computer and use it in GitHub Desktop.
A Service Container 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 Container class is a lightweight service container. | |
* | |
* ...and it fits in a tweet. | |
* | |
* @author Quentin Schuler aka Sukei <[email protected]> | |
*/ | |
class Container{private $s;function set($k,$c){$this->s[$k]=$c;}function get($k){return(is_a($v=$this->s[$k],'Closure'))?$v($this):$v;}} |
Author
sukei
commented
Feb 19, 2014
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment