Verze: 0.3
- 0.6 (master)
- 0.5
- 0.4
- 0.3
- 0.2
Dependency injection
Použití:
class A
{
public function hello(string $world): string
{
return "hello " . $world;
}
}
class B
{
private $a;
public function __construct(A $a)
{
$this->a = $a;
}
public function render()
{
return $this->a->hello("world");
}
}
// Bad
$a = new A();
$b = new B($a);
$b->render();
// Good
$container = new Container();
$b = $container->get(B::class);
$b->render(); // hello world