| Total Complexity | 4 |
| Total Lines | 35 |
| Duplicated Lines | 0 % |
| Changes | 1 | ||
| Bugs | 0 | Features | 0 |
| 1 | <?php declare(strict_types=1); |
||
| 13 | final class Maybe implements Choice |
||
| 14 | { |
||
| 15 | private $factory; |
||
| 16 | private $constraint; |
||
| 17 | |||
| 18 | private function __construct(ProxyFactory $factory, Satisfiable $constraint) |
||
| 19 | { |
||
| 20 | $this->factory = $factory; |
||
| 21 | $this->constraint = $constraint; |
||
| 22 | } |
||
| 23 | |||
| 24 | /** |
||
| 25 | * Creates a new maybe situation for the proxy factory. |
||
| 26 | * |
||
| 27 | * @param ProxyFactory $factory The factory to maybe use. |
||
| 28 | * @param Satisfiable $constraint The constraint that has to be met. |
||
| 29 | * @return Choice The new maybe factory. |
||
| 30 | */ |
||
| 31 | public static function the( |
||
| 32 | ProxyFactory $factory, |
||
| 33 | Satisfiable $constraint |
||
| 34 | ): Choice { |
||
| 35 | return new self($factory, $constraint); |
||
| 36 | } |
||
| 37 | |||
| 38 | /** @inheritdoc */ |
||
| 39 | public function shouldUseFor(array $data): bool |
||
| 40 | { |
||
| 41 | return $this->constraint->isSatisfiedBy($data); |
||
| 42 | } |
||
| 43 | |||
| 44 | /** @inheritdoc */ |
||
| 45 | public function create(array $knownData = []): Proxy |
||
| 48 | } |
||
| 49 | } |
||
| 50 |