| Total Complexity | 3 |
| Total Lines | 41 |
| Duplicated Lines | 0 % |
| Coverage | 100% |
| Changes | 0 | ||
| 1 | <?php |
||
| 13 | final class ConditionalStrategy |
||
| 14 | { |
||
| 15 | /** |
||
| 16 | * @var Strategy |
||
| 17 | */ |
||
| 18 | private $strategy; |
||
| 19 | |||
| 20 | /** |
||
| 21 | * @var callable |
||
| 22 | */ |
||
| 23 | private $condition; |
||
| 24 | |||
| 25 | /** |
||
| 26 | * ConditionalStrategy constructor. |
||
| 27 | * @param Strategy $strategy |
||
| 28 | * @param callable $condition |
||
| 29 | */ |
||
| 30 | 2 | public function __construct( |
|
| 31 | Strategy $strategy, |
||
| 32 | callable $condition |
||
| 33 | ) { |
||
| 34 | 2 | $this->strategy = $strategy; |
|
| 35 | 2 | $this->condition = $condition; |
|
| 36 | 2 | } |
|
| 37 | |||
| 38 | /** |
||
| 39 | * @return Strategy |
||
| 40 | */ |
||
| 41 | 1 | public function strategy(): Strategy |
|
| 42 | { |
||
| 43 | 1 | return $this->strategy; |
|
| 44 | } |
||
| 45 | |||
| 46 | |||
| 47 | /** |
||
| 48 | * @param mixed $data |
||
| 49 | * @return bool |
||
| 50 | */ |
||
| 51 | 2 | public function shouldBeApplied($data): bool |
|
| 54 | } |
||
| 55 | } |
||
| 56 |