- Svetoslav Stefanov
- Email: [email protected]
-
Acme Widget Co are the leading provider of made up widgets and they’ve contracted you to create a proof of concept for their new sales system.
-
They sell three products:
-
- Red Widget (Product Code: R01) - $32.95
-
- Green Widget (Product Code: G01) - $24.95
-
- Blue Widget (Product Code: B01) - $7.95
-
To incentivise customers to spend more, delivery costs are reduced based on the amount spent. Orders under $50 cost $4.95. For orders under $90, delivery costs $2.95. Orders of $90 or more have free delivery.
-
They are also experimenting with special offers. The initial offer will be “buy one red widget, get the second half price”
-
Your job is to implement the basket which needs to have the following interface
-
- It is initialised with the product catalogue, delivery charge rules, and offers (the format of how these are passed it up to you)
-
- It has an add method that takes the product code as a parameter.
-
- It has a total method that returns the total cost of the basket, taking into account the delivery and offer rules.
- Clone the repository
git clone https://github.com/SvetoslavStefanov/architech-labs-code-test.git
- Navigate to the project directory
cd architech-labs-code-test
- Run the Docker container
docker-compose run php
and follow the instructions in the cli menu - Run phpunit tests
composer phpunit
- Run PHPStan
composer phpstan
From this point you'll navigate our Menu from which you can choose the desired action.
- Separation of logic (different classes for each of the available objects - Basket, Product, Offer, Catalogue)
- CLI Menu interface
- Error handling
- No hardcoded values
- Using Interfaces
- Dependency Injection
- Dockerized environment
- PHP Unit tests
- PHPStan