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