Created
March 21, 2019 08:21
-
-
Save kanian/6d21f667a658665222d490e7d7f01e44 to your computer and use it in GitHub Desktop.
Setting dependencies on a container
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 Kanian\ContainerX; | |
use Psr\Container\ContainerInterface; | |
class Container implements ContainerInterface | |
{ | |
protected $instances = []; | |
//... | |
public function set($abstract, $concrete = null) | |
{ | |
if ($concrete === null) { | |
$concrete = $abstract; | |
} | |
$this->instances[$abstract] = $concrete; | |
} | |
//... | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment