| Total Complexity | 5 |
| Total Lines | 30 |
| Duplicated Lines | 0 % |
| Coverage | 100% |
| Changes | 0 | ||
| 1 | <?php |
||
| 9 | class DeprecatedConfigParser |
||
| 10 | { |
||
| 11 | 5 | public function __invoke(array $config): array |
|
| 12 | { |
||
| 13 | 5 | return compose([$this, 'parseNotFoundRedirect'], [$this, 'removeSecretKey'])($config); |
|
| 14 | } |
||
| 15 | |||
| 16 | 5 | public function parseNotFoundRedirect(array $config): array |
|
| 17 | { |
||
| 18 | // If the new config value is already set, keep it |
||
| 19 | 5 | if (isset($config['not_found_redirects']['invalid_short_url'])) { |
|
| 20 | 1 | return $config; |
|
| 21 | } |
||
| 22 | |||
| 23 | 4 | $oldRedirectEnabled = $config['url_shortener']['not_found_short_url']['enable_redirection'] ?? false; |
|
| 24 | 4 | if (! $oldRedirectEnabled) { |
|
| 25 | 2 | return $config; |
|
| 26 | } |
||
| 27 | |||
| 28 | 2 | $oldRedirectValue = $config['url_shortener']['not_found_short_url']['redirect_to'] ?? null; |
|
| 29 | 2 | $config['not_found_redirects']['invalid_short_url'] = $oldRedirectValue; |
|
| 30 | |||
| 31 | 2 | return $config; |
|
| 32 | } |
||
| 33 | |||
| 34 | 5 | public function removeSecretKey(array $config): array |
|
| 39 | } |
||
| 40 | } |
||
| 41 |