A user should be able to enter details like weight and current activity level and based on those values the application should calculate the necessary calories intake.
Requires a CaloriesCalculator class.
Class must contain method to calculate the total of calories based on the weight in kg and activity level.
Class must contain method to calculate the macronutrients distribution based on the provided calories value and percentage of protein, carbohydrates and fats.
POST'/calculate/calories/' - POST request endpoint responsible to calculate the total of calories.
Example request:
{"weight": 93, "activityLevel": "moderate" }
POST'/calculate/macronutrients/' - POST request endpoint responsible to calculate the macronutrients distribution.
Example request:
{"calories": 3060, "protein": 30, "carbohydrates": 60, "fats": 10}
Refactor
Initialise this new class in the index.php file and execute logic to support those two requests.
Write Unit tests to each method present in this class.
Description
A user should be able to enter details like weight and current activity level and based on those values the application should calculate the necessary calories intake.
Requires a CaloriesCalculator class.
Class must contain method to calculate the total of calories based on the weight in kg and activity level.
Class must contain method to calculate the macronutrients distribution based on the provided calories value and percentage of protein, carbohydrates and fats.
POST
'/calculate/calories/'
- POST request endpoint responsible to calculate the total of calories.Example request:
{"weight": 93, "activityLevel": "moderate" }
POST
'/calculate/macronutrients/'
- POST request endpoint responsible to calculate the macronutrients distribution.Example request:
{"calories": 3060, "protein": 30, "carbohydrates": 60, "fats": 10}
Refactor
Initialise this new class in the
index.php
file and execute logic to support those two requests.Write Unit tests to each method present in this class.