Mixer now returns a MixedRecipe instead of array

This commit is contained in:
2019-07-10 23:48:03 +02:00
parent 04f357fc0a
commit efdc860df2
5 changed files with 59 additions and 36 deletions

View File

@ -1,31 +0,0 @@
<?php
namespace NoccyLabs\Juicer\Recipe\Mixer;
use NoccyLabs\Juicer\Ingredient\Base;
use NoccyLabs\Juicer\Recipe\RecipeInterface;
class MeasuredRecipe
{
public function __construct(RecipeInterface $recipe, array $mixedIngredients)
{
}
public function getTotalFlavorMl()
{
}
public function getTotalFlavorPercent()
{
}
public function getTotalFlavorGrams()
{
}
}

View File

@ -0,0 +1,50 @@
<?php
namespace NoccyLabs\Juicer\Recipe\Mixer;
use NoccyLabs\Juicer\Ingredient\Base;
use NoccyLabs\Juicer\Recipe\RecipeInterface;
class MixedRecipe
{
protected $recipe;
protected $mixedIngredients = [];
public function __construct(RecipeInterface $recipe, array $mixedIngredients)
{
$this->recipe = $recipe;
$this->mixedIngredients = $mixedIngredients;
}
public function getIngredients(): array
{
return $this->recipe->getIngredients();
}
public function getMeasuredIngredients(): array
{
return $this->mixedIngredients;
}
public function getTotalFlavorMl(): float
{
}
public function getTotalFlavorPercent(): float
{
}
public function getTotalFlavorGrams(): float
{
}
public function getSpecificGravity(): float
{
}
}

View File

@ -10,7 +10,7 @@ use NoccyLabs\Juicer\Ingredient\NicotineBase;
class Mixer
{
public function mixRecipe(RecipeInterface $recipe, int $volume, Base $base, int $nicotineStrength, ?NicotineBase $nicotineBase=null)
public function mixRecipe(RecipeInterface $recipe, int $volume, Base $base, int $nicotineStrength, ?NicotineBase $nicotineBase=null): MixedRecipe
{
// Array holding our final list
$mixed = [];
@ -55,7 +55,8 @@ class Mixer
$mixed[] = new MeasuredIngredient($ingredient, $ingredientPercent, $volume * $floatPercent);
}
return $mixed;
$mixedRecipe = new MixedRecipe($recipe, $mixed);
return $mixedRecipe;
}
}