Mixer now returns a MixedRecipe instead of array
This commit is contained in:
parent
04f357fc0a
commit
efdc860df2
@ -13,5 +13,8 @@
|
||||
"psr-4": {
|
||||
"NoccyLabs\\Juicer\\": "src/"
|
||||
}
|
||||
},
|
||||
"require": {
|
||||
"php": "~7.0"
|
||||
}
|
||||
}
|
@ -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()
|
||||
{
|
||||
|
||||
}
|
||||
}
|
50
src/Recipe/Mixer/MixedRecipe.php
Normal file
50
src/Recipe/Mixer/MixedRecipe.php
Normal 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
|
||||
{
|
||||
|
||||
}
|
||||
}
|
@ -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;
|
||||
}
|
||||
|
||||
}
|
@ -29,7 +29,7 @@ class MixerTest extends \PhpUnit\Framework\TestCase
|
||||
$mixer = new Mixer();
|
||||
|
||||
$base = new Base($base);
|
||||
$mixed = $mixer->mixRecipe($recipe, $amount, $base, 0);
|
||||
$mixed = $mixer->mixRecipe($recipe, $amount, $base, 0)->getMeasuredIngredients();
|
||||
|
||||
$this->assertCount(count($assertBases), $mixed);
|
||||
$mixedAmount = 0;
|
||||
@ -63,7 +63,7 @@ class MixerTest extends \PhpUnit\Framework\TestCase
|
||||
{
|
||||
$mixer = new Mixer();
|
||||
$base = new Base($base);
|
||||
$mixed = $mixer->mixRecipe($recipe, $amount, $base, 0);
|
||||
$mixed = $mixer->mixRecipe($recipe, $amount, $base, 0)->getMeasuredIngredients();
|
||||
|
||||
$expectedCount = count($base->getComponents()) + count($recipe->getIngredients());
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user