Skip to content

Instantly share code, notes, and snippets.

@kanian
Created March 21, 2019 08:21
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save kanian/6d21f667a658665222d490e7d7f01e44 to your computer and use it in GitHub Desktop.
Save kanian/6d21f667a658665222d490e7d7f01e44 to your computer and use it in GitHub Desktop.
Setting dependencies on a container
<?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