| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
| Name | Name | Last commit date | ||
|---|---|---|---|---|
parent directory.. | ||||
To implement a loosely coupled architecture in order to get better testable, maintainable and extendable code.
DatabaseConfiguration gets injected and DatabaseConnection will get all that it needs from $config. Without DI, the configuration would be created directly in DatabaseConnection, which is not very good for testing and extending it.
You can also find these code on GitHub
DatabaseConfiguration.php
.. literalinclude:: DatabaseConfiguration.php :language: php :linenos:
DatabaseConnection.php
.. literalinclude:: DatabaseConnection.php :language: php :linenos:
Tests/DependencyInjectionTest.php
.. literalinclude:: Tests/DependencyInjectionTest.php :language: php :linenos:
| Back | FazBrowse Home | New Git URL |