| Total Complexity | 8 |
| Total Lines | 65 |
| Duplicated Lines | 0 % |
| Changes | 1 | ||
| Bugs | 0 | Features | 0 |
| 1 | <?php |
||
| 7 | final class InsertValueBeforeKey implements DataModifierInterface |
||
| 8 | { |
||
| 9 | /** |
||
| 10 | * @var int|string|null |
||
| 11 | */ |
||
| 12 | private $key = null; |
||
| 13 | |||
| 14 | /** |
||
| 15 | * @var mixed |
||
| 16 | */ |
||
| 17 | private $value = null; |
||
| 18 | |||
| 19 | /** |
||
| 20 | * @var int|string|null |
||
| 21 | */ |
||
| 22 | private $beforeKey = null; |
||
| 23 | |||
| 24 | /** |
||
| 25 | * @param int|string $key |
||
| 26 | * @return self |
||
| 27 | */ |
||
| 28 | public function withKey($key): self |
||
| 29 | { |
||
| 30 | $new = clone $this; |
||
| 31 | $new->key = $key; |
||
| 32 | return $new; |
||
| 33 | } |
||
| 34 | |||
| 35 | /** |
||
| 36 | * @param mixed $value |
||
| 37 | * @return self |
||
| 38 | */ |
||
| 39 | public function setValue($value): self |
||
| 40 | { |
||
| 41 | $new = clone $this; |
||
| 42 | $new->value = $value; |
||
| 43 | return $new; |
||
| 44 | } |
||
| 45 | |||
| 46 | /** |
||
| 47 | * @param int|string $key |
||
| 48 | * @return self |
||
| 49 | */ |
||
| 50 | public function beforeKey($key): self |
||
| 51 | { |
||
| 52 | $new = clone $this; |
||
| 53 | $new->beforeKey = $key; |
||
| 54 | return $new; |
||
| 55 | } |
||
| 56 | |||
| 57 | public function apply(array $data): array |
||
| 72 | } |
||
| 73 | } |
||
| 74 |