Code Coverage
 
Lines
Functions and Methods
Classes and Traits
Total
100.00% covered (success)
100.00%
12 / 12
100.00% covered (success)
100.00%
7 / 7
CRAP
100.00% covered (success)
100.00%
1 / 1
ConfigRenameOperation
100.00% covered (success)
100.00%
12 / 12
100.00% covered (success)
100.00%
7 / 7
7
100.00% covered (success)
100.00%
1 / 1
 __construct
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
1
 getType
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
1
 getDescription
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
1
 getOldKey
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
1
 getNewKey
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
1
 execute
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
1
 toArray
100.00% covered (success)
100.00%
6 / 6
100.00% covered (success)
100.00%
1 / 1
1
1<?php
2
3/**
4 * Configuration rename operation for migrations.
5 *
6 * This Source Code Form is subject to the terms of the Mozilla Public License,
7 * v. 2.0. If a copy of the MPL was not distributed with this file, You can
8 * obtain one at https://mozilla.org/MPL/2.0/.
9 *
10 * @package   phpMyFAQ
11 * @author    Thorsten Rinne <thorsten@phpmyfaq.de>
12 * @copyright 2023-2026 phpMyFAQ Team
13 * @license   https://www.mozilla.org/MPL/2.0/ Mozilla Public License Version 2.0
14 * @link      https://www.phpmyfaq.de
15 * @since     2026-01-25
16 */
17
18declare(strict_types=1);
19
20namespace phpMyFAQ\Setup\Migration\Operations;
21
22use phpMyFAQ\Configuration;
23
24readonly class ConfigRenameOperation implements OperationInterface
25{
26    public function __construct(
27        private Configuration $configuration,
28        private string $oldKey,
29        private string $newKey,
30    ) {
31    }
32
33    public function getType(): string
34    {
35        return 'config_rename';
36    }
37
38    public function getDescription(): string
39    {
40        return sprintf('Rename configuration: %s -> %s', $this->oldKey, $this->newKey);
41    }
42
43    public function getOldKey(): string
44    {
45        return $this->oldKey;
46    }
47
48    public function getNewKey(): string
49    {
50        return $this->newKey;
51    }
52
53    public function execute(): bool
54    {
55        return $this->configuration->rename($this->oldKey, $this->newKey);
56    }
57
58    public function toArray(): array
59    {
60        return [
61            'type' => $this->getType(),
62            'description' => $this->getDescription(),
63            'oldKey' => $this->oldKey,
64            'newKey' => $this->newKey,
65        ];
66    }
67}