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