Added examples, improved recipe implementation

This commit is contained in:
2019-07-09 17:59:45 +02:00
parent 922d9f09dd
commit 04f357fc0a
3 changed files with 88 additions and 7 deletions

View File

@ -24,39 +24,59 @@ class Recipe implements RecipeInterface
/** @var IngredientInterface[] */
protected $ingredients = [];
public function setRecipeName(?string $name)
public function setRecipeName(?string $name): Recipe
{
$this->name = $name;
return $this;
}
public function setRecipeAuthor(?string $author)
public function setRecipeAuthor(?string $author): Recipe
{
$this->author = $author;
return $this;
}
public function setTags(array $tags)
public function setTags(array $tags): Recipe
{
$this->tags = $tags;
return $this;
}
public function addTag(string $tag)
public function addTag(string $tag): Recipe
{
$this->tags[] = $tag;
return $this;
}
public function setDescription(?string $description)
public function hasTag(string $tag): bool
{
return in_array($tag, $this->tags);
}
public function removeTag(string $tag): Recipe
{
$this->tags = array_filter($this->tags, function ($input) use ($tag) {
return $input != $tag;
});
return $this;
}
public function setDescription(?string $description): Recipe
{
$this->description = $description;
return $this;
}
public function addIngredient(IngredientInterface $ingredient)
public function addIngredient(IngredientInterface $ingredient): Recipe
{
$this->ingredients[] = $ingredient;
return $this;
}
public function setExtra(array $extra)
public function setExtra(array $extra): Recipe
{
$this->extra = $extra;
return $this;
}
/**