This is a very simple project created during a course at Alura Platform to study SOLID principles with PHP. The objective is to refactor an existing project using these principles.
SOLID is a mnemonic acronym for five design principles intended to make object-oriented designs more understandable, flexible, and maintainable. They are:
- Single Responsibility Principle
- Open / Closed Principle
- Liskov Substitution Principle
- Interface Segregation Principle
- Dependency Inversion Principle
Every class/method SHOULD have only one reason to change.
Software entities (classes, modules, functions, etc.) SHOULD be open for extension, but closed for modification.
Subclasses should be substitutable for their base classes. Child classes must never violate the type definitions of the parent class.
High-level modules should not depend on low-level modules; both should depend on abstractions.
Clients should not be forced to depend upon interfaces that they do not use.
This project requires Composer to install its dependencies. If you don't have it installed, go to Composer for more information.
After installing Composer, you can use the command to install dependencies:
composer install
Pdepend is a package used to generate reports on dependencies in PHP.
If you already have used the command composer install
to this project, you can skip this step.
To install pdepend
composer require "pdepend/pdepend:2.10.3"
vendor\bin\pdepend.bat
vendor\bin\pdepend.bat --jdepend-chart=C:\wamp64\www\learning-solid-with-php\grafico2 C:\wamp64\www\learning-solid-with-php\src
The first image was generated in the begging of the project and shows that the project is far from ideal.
The second image shows that the work in progress is coming up with a good result.
And finally, this project reaches a more ideal state when concrete class depends more on abstract classes than the opposite.
To make tests i used PHPUnit.
If you already have used the command composer install
to this project, you can skip this step.
composer require --dev phpunit/phpunit ^9
vendor\bin\phpunit --version
vendor\bin\phpunit
A file report 'testes-executados.txt' will be created with the results of all tests.