| Conditions | 5 |
| Paths | 6 |
| Total Lines | 17 |
| Code Lines | 9 |
| Lines | 0 |
| Ratio | 0 % |
| Tests | 10 |
| CRAP Score | 5 |
| Changes | 0 | ||
| 1 | <?php |
||
| 56 | 4 | public function apply(array $data): array |
|
| 57 | { |
||
| 58 | 4 | if (!array_key_exists($this->key, $data)) { |
|
| 59 | 1 | return $data; |
|
| 60 | } |
||
| 61 | |||
| 62 | 3 | $result = []; |
|
| 63 | 3 | foreach ($data as $k => $v) { |
|
| 64 | 3 | if ($k === $this->beforeKey) { |
|
| 65 | 3 | $result[$this->key] = $data[$this->key]; |
|
| 66 | } |
||
| 67 | 3 | if ($k !== $this->key) { |
|
| 68 | 3 | $result[$k] = $v; |
|
| 69 | } |
||
| 70 | } |
||
| 71 | |||
| 72 | 3 | return $result; |
|
| 73 | } |
||
| 75 |