<?php
$simpleCart = new SimpleCartFacade();
$simpleCart->add('G01');
$simpleCart->add('R01');
$simpleCart->add('R01');
$simpleCart->add('R01');
$total = $simpleCart->total();
- json file is used as products database
- price precision is 2 (like 10.99)
- I'm skipping
$
sign in prices anywhere (assuming it is only task description) - not integrating phpcs+fixer or phpmd since it was not requirement (like phpstan)
- default phpstorm configuration was used for coding format
- code coverage was not any kind of goal instead of meaningful tests and TDD
- docker
- docker-compose
docker-compose up -d
- inside container
composer install
or simplydocker exec -it php_sample_cart bash -c "composer install"
- unit
docker exec -it php_sample_cart bash -c "vendor/bin/phpunit --configuration phpunit.xml --testsuite 'Unit Tests'"
- integration
docker exec -it php_sample_cart bash -c "vendor/bin/phpunit --configuration phpunit.xml --testsuite 'Integration Tests'"
- unit + integration:
docker exec -it php_sample_cart bash -c "composer test"
- static tests (
phpstan
)docker exec -it php_sample_cart bash -c "composer analyse"