Хабр Курсы для всех
РЕКЛАМА
Практикум, Хекслет, SkyPro, авторские курсы — собрали всех и попросили скидки. Осталось выбрать!
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