mirror of
https://github.com/codeguy/php-the-right-way.git
synced 2025-08-08 23:16:36 +02:00
Typos and further change re comments
This commit is contained in:
committed by
Josh Lockhart
parent
aaebe65095
commit
4bdbd868c3
@@ -14,7 +14,7 @@ In terms of Dependency Injection, this means loosening our dependencies by contr
|
||||
|
||||
For years, PHP frameworks have been achieving Inversion of Control, however, the question became, which part of control
|
||||
are you inverting, and where to? For example, MVC frameworks would generally provide a super object or base controller that other
|
||||
controllers must extend to gain access to it's dependencies. This **is** Inversion of Control, however, instead of loosening
|
||||
controllers must extend to gain access to its dependencies. This **is** Inversion of Control, however, instead of loosening
|
||||
dependencies, this method simply moved them.
|
||||
|
||||
Dependency Injection allows us to more elegantly solve this problem by only injecting the dependencies we need, when we need them,
|
||||
@@ -45,7 +45,7 @@ interface AdapterInterface {}
|
||||
class MysqlAdapter implements AdapterInterface {}
|
||||
{% endhighlight %}
|
||||
|
||||
There are several benefits to the Database class now depending on an interface rather than a concretion.
|
||||
There are several benefits to the `Database` class now depending on an interface rather than a concretion.
|
||||
|
||||
Consider that you are working in a team and the adapter is being worked on by a colleague. In our first example, we would have
|
||||
to wait for said colleague to finish the adapter before we could properly mock it for our unit tests. Now that the dependency
|
||||
|
@@ -6,7 +6,7 @@ isChild: true
|
||||
|
||||
The first thing you should understand about Dependency Injection Containers is that they are not the same thing as Dependency
|
||||
Injection. A container is a convenience utility that helps us implement Dependency Injection, however, they can be and often
|
||||
are misused to implement an anti pattern, Service Location. Using a container as a Service Locator within your classes arguably
|
||||
are misused to implement an anti-pattern, Service Location. Injecting a DI container as a Service Locator in to your classes arguably
|
||||
creates a harder dependency on the container than the dependency you are replacing. It also makes your code much less transparent
|
||||
and ultimately harder to test.
|
||||
|
||||
|
Reference in New Issue
Block a user