AbstractRecipeDecorator::__construct()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 1

Importance

Changes 0
Metric Value
eloc 1
dl 0
loc 3
ccs 2
cts 2
cp 1
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 1
crap 1
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Lit\Air\Recipe\Decorator;
6
7
use Lit\Air\Recipe\RecipeInterface;
8
use Lit\Air\Recipe\RecipeTrait;
9
10
/**
11
 * Decorator or wrapper recipe which change another recipe's behavior
12
 */
13
abstract class AbstractRecipeDecorator implements RecipeInterface
14
{
15
    use RecipeTrait;
16
17
    /**
18
     * @var RecipeInterface
19
     */
20
    protected $recipe;
21
    protected $option;
22
23 4
    public function __construct(RecipeInterface $recipe)
24
    {
25 4
        $this->recipe = $recipe;
26 4
    }
27
28
    /**
29
     * Decorates provided recipe.
30
     *
31
     * @param RecipeInterface $recipe The inner recipe.
32
     * @return AbstractRecipeDecorator A new recipe with decorated behavior
33
     */
34 4
    public static function decorate(RecipeInterface $recipe): self
35
    {
36 4
        return new static($recipe);
37
    }
38
39
    /**
40
     * Option setter
41
     *
42
     * @param mixed $option The option value.
43
     * @return AbstractRecipeDecorator
44
     */
45 2
    public function setOption($option): self
46
    {
47 2
        $this->option = $option;
48 2
        return $this;
49
    }
50
}
51