1 | <?php |
||
15 | final class EnabledFixerResolver |
||
16 | { |
||
17 | /** |
||
18 | * @var PhpCsFixerConfigurationInterface |
||
19 | */ |
||
20 | private $configuration; |
||
21 | |||
22 | /** |
||
23 | * @var ConfigurationResolverFactory |
||
24 | */ |
||
25 | private $configurationResolverFactory; |
||
26 | |||
27 | /** |
||
28 | * @var FixerInterface[] |
||
29 | */ |
||
30 | private $enabledFixers = []; |
||
31 | |||
32 | 1 | public function __construct( |
|
39 | |||
40 | /** |
||
41 | * @return FixerInterface[] |
||
42 | */ |
||
43 | 1 | public function getEnabledFixers() |
|
56 | |||
57 | 1 | private function addFixersByLevel(ConfigurationResolver $configurationResolver) |
|
58 | { |
||
59 | 1 | $excludedFixers = $this->getExcludedFixersAsString(); |
|
60 | 1 | foreach ($this->configuration->getActiveFixerLevels() as $level) { |
|
61 | 1 | $currentConfigurationResolver = clone $configurationResolver; |
|
62 | 1 | if ($excludedFixers) { |
|
63 | 1 | $currentConfigurationResolver->setOption('fixers', $excludedFixers); |
|
64 | } |
||
65 | 1 | $currentConfigurationResolver->setOption('level', $level); |
|
66 | 1 | $currentConfigurationResolver->resolve(); |
|
67 | |||
68 | 1 | $this->enabledFixers = array_merge($this->enabledFixers, $currentConfigurationResolver->getFixers()); |
|
69 | } |
||
70 | 1 | } |
|
71 | |||
72 | /** |
||
73 | * @return string |
||
74 | */ |
||
75 | 1 | private function getExcludedFixersAsString() |
|
84 | |||
85 | /** |
||
86 | * @return array |
||
87 | */ |
||
88 | 1 | private function addCustomFixers(ConfigurationResolver $configurationResolver) |
|
101 | |||
102 | /** |
||
103 | * @return string |
||
104 | */ |
||
105 | 1 | private function getEnabledFixersAsString() |
|
114 | } |
||
115 |