| Total Complexity | 5 |
| Total Lines | 46 |
| Duplicated Lines | 0 % |
| Changes | 1 | ||
| Bugs | 0 | Features | 0 |
| 1 | <?php |
||
| 16 | final class ForDataSets implements DeserializationOption |
||
| 17 | { |
||
| 18 | /** @var Satisfiable */ |
||
| 19 | private $condition; |
||
| 20 | /** @var Deserializer */ |
||
| 21 | private $deserialize; |
||
| 22 | |||
| 23 | private function __construct(Satisfiable $condition, Deserializer $deserialize) |
||
| 24 | { |
||
| 25 | $this->condition = $condition; |
||
| 26 | $this->deserialize = $deserialize; |
||
| 27 | } |
||
| 28 | |||
| 29 | /** |
||
| 30 | * Produce an option for data sets that pass the condition. |
||
| 31 | * |
||
| 32 | * @param Satisfiable $condition The condition that must be satisfied by |
||
| 33 | * the data set. |
||
| 34 | * @param Deserializer $deserialize The deserializer that will deserialize |
||
| 35 | * satisfying data sets. |
||
| 36 | * @return DeserializationOption The option object to supply to the |
||
| 37 | * @see OneOfThese::deserializers() method. |
||
| 38 | */ |
||
| 39 | public static function that( |
||
| 40 | Satisfiable $condition, |
||
| 41 | Deserializer $deserialize |
||
| 42 | ): DeserializationOption { |
||
| 43 | return new ForDataSets($condition, $deserialize); |
||
| 44 | } |
||
| 45 | |||
| 46 | /** @inheritdoc */ |
||
| 47 | public function isSatisfiedBy($input): bool |
||
| 48 | { |
||
| 49 | return $this->condition->isSatisfiedBy($input); |
||
| 50 | } |
||
| 51 | |||
| 52 | /** @inheritdoc */ |
||
| 53 | public function from(array $input) |
||
| 56 | } |
||
| 57 | |||
| 58 | /** @inheritdoc */ |
||
| 59 | public function typeFor(array $input): string |
||
| 64 |