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