| Conditions | 5 |
| Paths | 6 |
| Total Lines | 17 |
| Code Lines | 9 |
| Lines | 0 |
| Ratio | 0 % |
| Tests | 10 |
| CRAP Score | 5 |
| Changes | 0 | ||
| 1 | <?php |
||
| 92 | 5 | public function apply(array $data): array |
|
| 93 | { |
||
| 94 | 5 | if (!array_key_exists($this->key, $data)) { |
|
| 95 | 1 | return $data; |
|
| 96 | } |
||
| 97 | |||
| 98 | 4 | $result = []; |
|
| 99 | 4 | foreach ($data as $k => $v) { |
|
| 100 | 4 | if ($k === $this->beforeKey) { |
|
| 101 | 4 | $result[$this->key] = $data[$this->key]; |
|
| 102 | } |
||
| 103 | 4 | if ($k !== $this->key) { |
|
| 104 | 4 | $result[$k] = $v; |
|
| 105 | } |
||
| 106 | } |
||
| 107 | |||
| 108 | 4 | return $result; |
|
| 109 | } |
||
| 111 |