🍎🥕 Fruits and Vegetables

🎯 Goal

We want to build a service which will take a request.json and:

  • Process the file and create two separate collections for Fruits and Vegetables
  • Each collection has methods like add(), remove(), list();
  • Units have to be stored as grams;
  • As a bonus you might consider giving option to decide which units are returned (kilograms/grams);
  • As a bonus you might consider how to implement search() method collections;

✔️ How can I check if my code is working?

You have two ways of moving on:

  • You call the Service from PHPUnit test like it's done in dummy test (just run bin/phpunit from the console)

or

  • You create a Controller which will be calling the service with a json payload

💡 Hints before you start working on it

  • Keep KISS, DRY, YAGNI, SOLID principles in mind
  • Timebox your work - we expect that you would spend between 3 and 4 hours.
  • Your code should be tested

When you are finished

  • Please upload your code to a public git repository (i.e. GitHub, Gitlab)

🐳 Docker image

Optional. Just here if you want to run it isolated.

📥 Pulling image

docker pull tturkowski/fruits-and-vegetables

🧱 Building image

docker build -t tturkowski/fruits-and-vegetables -f docker/Dockerfile .

🏃‍♂️ Running container

docker run -it -w/app -v$(pwd):/app tturkowski/fruits-and-vegetables sh 

🛂 Running tests

docker run -it -w/app -v$(pwd):/app tturkowski/fruits-and-vegetables bin/phpunit

⌨️ Run development server

docker run -it -w/app -v$(pwd):/app -p8484:8484 tturkowski/fruits-and-vegetables php -S 0.0.0.0:8484 -t /app/public
# Open http://127.0.0.1:8484 in your browser