LabiciIvan / php-api-nutritional-project

A PHP API nutritional project
0 stars 0 forks source link

Nutrition Class - the base class of the application. #2

Closed LabiciIvan closed 3 months ago

LabiciIvan commented 3 months ago

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.