| Total Complexity | 5 |
| Total Lines | 39 |
| Duplicated Lines | 0 % |
| Changes | 0 | ||
| 1 | <?php |
||
| 9 | final class Defaults implements MapsProperty |
||
| 10 | { |
||
| 11 | private $defaultValue; |
||
| 12 | private $mapping; |
||
| 13 | |||
| 14 | private function __construct($defaultValue, MapsProperty $mapping) |
||
| 15 | { |
||
| 16 | $this->defaultValue = $defaultValue; |
||
| 17 | $this->mapping = $mapping; |
||
| 18 | } |
||
| 19 | |||
| 20 | /** |
||
| 21 | * Sets up a default value for a property mapping. |
||
| 22 | * |
||
| 23 | * @param mixed $defaultValue The value to assign if the original |
||
| 24 | * mapping failed. |
||
| 25 | * @param MapsProperty $mapping The original mapping, to try first. |
||
| 26 | * @return MapsProperty The property mapping with default. |
||
| 27 | */ |
||
| 28 | public static function to( |
||
| 29 | $defaultValue, |
||
| 30 | MapsProperty $mapping |
||
| 31 | ): MapsProperty { |
||
| 32 | return new self($defaultValue, $mapping); |
||
| 33 | } |
||
| 34 | |||
| 35 | /** @inheritdoc */ |
||
| 36 | public function name(): string |
||
| 39 | } |
||
| 40 | |||
| 41 | /** @inheritdoc */ |
||
| 42 | public function value(array $data, $owner = null) |
||
| 48 | } |
||
| 49 | } |
||
| 50 | } |
||
| 51 |