Хабр Курсы для всех
РЕКЛАМА
Большая витрина: от крупнейших школ до частных авторов. Сравнивайте по цене, длительности, формату и выбирайте самый подходящий курс!
class DIC {
function getService1()
{
return new Service1();
}
function getService2()
{
return Serivce2($this->getService1());
}
}
$dic = new DIC();
$service1 = $dir->getService1();
with Service Locator is that it hides a class’ dependencies, causing run-time errors instead of compile-time errors, as well as making the code more difficult to maintain because it becomes unclear when you would be introducing a breaking change.
Внедрение зависимости c Inversion