This is a Cookie recipe finder by point of its ingredients.
First build the image:
docker build . -t cookie
Then run the finder command:
docker run --rm -i -t cookie php /var/www/html/bin/run.php finder
First create/copy .env
file.
cp .env_example .env
Then install libraries with composer:
composer install
Note 1: make sure the logs
directory is writeable.
or disable logging by setting IS_DEBUG
to 0
.
php bin/run.php finder
you can find some unit tests in the /tests
directory. to run them
./vendor/bin/phpunit tests
a simple symfony console app is created in the bin/run.php
file. it uses a command in
src/Console/FindRecipeCommand.php
. the initialization of data placed there. so if we want a new ingredient we can
add there.
to create an ingredient you can use:
$ingredient = new Ingredient(
new Name("Cinnamon"),
new Capacity(2),
new Durability(3),
new Flavor(-2),
new Texture(-1),
new Calories(3),
);
to add Quantity to the ingredient, first need a Measurement:
$measurement = new Measurement(44, UnitVolume::teaspoons())
$ingredientQuantity = new IngredientQuantity(
$ingredient,
$measurement
);
then we can put some amount of ingredients into a container (here a bowl). the bowl should have a capacity. in this test we set it 100 tea-spoon. but it's totally adjustable.
$bowl = new Bowl(
new Measurement(100, UnitVolume::teaspoons()
$ingredientQuantity
);
to find out the score of the bowl. Just put the bowl in to calculator:
$calculator = new TasteCalculator(
$bowl,
);
$score = $calculator->getScore();
To find out the best recipe check out the src/Console/FindRecipeCommand.php
file.