Requirements:
- GNU make
- Docker 19.03.0+
- Docker Compose
-
Docker Composeis used to manage the containers -
PHPversion 7.4 running on Alpine -
Xdebugis running on port 9003 (additional config in docker/php-fpm/dev.xdebug.ini)
-
No framework used
-
PHPUnit for tests
-
PHPCS for static analysis using PSR-12
Created classes to enforce the enums in the Product and encapsulate this logic there.
Created a ProductFetcher interface to abstract the processes of getting the product itself from the different data sources and formats, so more formats can be added from it.
Some auxiliary classes were used in the ProductFetcher (reader, normalizer) that could possibly be abstracted when having more cases to make sure the abstraction makes sense and is the right one.
Unit tests were used trying to cover most of the logic, but I think it is necessary to add a higher level too (integration, functional, acceptance, e2e, etc) so that the integrated code can be checked.
GNU make is being used for shortcuts of Docker and Docker Compose commands.
When starting the application for the first time, run the following command:
make initial-setup
It should build the containers and do a composer install.
For getting the Json output of the application:
make print-products
This is a list of some additional useful commands, more can be found in the Makefile
runfor starting the container in interactive mode for shcode-styleto run static code analyzersteststo run the testslogsto print the docker logs