Lines 100.00% 12 / 12
Methods 100.00% 7 / 7
Classes 100.00% 1 / 1
Covered by tests of size
Name Lines Methods CRAP
 __construct 100.00% 1 / 1 100.00% 1 / 1 1
 getType 100.00% 1 / 1 100.00% 1 / 1 1
 getDescription 100.00% 1 / 1 100.00% 1 / 1 1
 getOldKey 100.00% 1 / 1 100.00% 1 / 1 1
 getNewKey 100.00% 1 / 1 100.00% 1 / 1 1
 execute 100.00% 1 / 1 100.00% 1 / 1 1
 toArray 100.00% 6 / 6 100.00% 1 / 1 1
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}