AbstractRecipeDecorator   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 36
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
wmc 3
eloc 8
dl 0
loc 36
ccs 8
cts 8
cp 1
rs 10
c 0
b 0
f 0

3 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 3 1
A decorate() 0 3 1
A setOption() 0 4 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