Conditions | 6 |
Paths | 24 |
Total Lines | 105 |
Code Lines | 64 |
Lines | 0 |
Ratio | 0 % |
Changes | 0 |
Small methods make your code easier to understand, in particular if combined with a good name. Besides, if your method is small, finding a good name is usually much easier.
For example, if you find yourself adding comments to a method's body, this is usually a good sign to extract the commented part to a new method, and use the comment as a starting point when coming up with a good name for this new method.
Commonly applied refactorings include:
If many parameters/temporary variables are present:
1 | <?php |
||
93 | protected function execute(InputInterface $input, OutputInterface $output) |
||
94 | { |
||
95 | $composer = $this->getComposer(); |
||
96 | |||
97 | $isDevMode = !$input->getOption('no-dev'); |
||
98 | $withExcluded = $input->getOption('excluded') || $input->getOption('with-excludes'); |
||
99 | $withAffected = $input->getOption('with-affected'); |
||
100 | $beBrief = $input->getOption('brief'); |
||
101 | |||
102 | $filters = array( |
||
103 | PatchDefinition::SOURCE => $input->getOption('filter'), |
||
104 | PatchDefinition::TARGETS => $input->getArgument('targets') |
||
105 | ); |
||
106 | |||
107 | $statusFilters = array_map('strtolower', $input->getOption('status')); |
||
|
|||
108 | |||
109 | $pluginConfig = $this->createConfigWithEnabledSources($composer); |
||
110 | |||
111 | |||
112 | $filteredPool = $this->createLoaderPool(); |
||
113 | |||
114 | $packageInfoResolver = new \Vaimo\ComposerPatches\Package\InfoResolver( |
||
115 | $composer->getInstallationManager(), |
||
116 | $composer->getConfig()->get(\Vaimo\ComposerPatches\Composer\ConfigKeys::VENDOR_DIR) |
||
117 | ); |
||
118 | |||
119 | $unfilteredPool = $this->createLoaderPool(array( |
||
120 | 'constraints' => false, |
||
121 | 'platform' => false, |
||
122 | 'local-exclude' => false, |
||
123 | 'root-patch' => false, |
||
124 | 'global-exclude' => false, |
||
125 | 'targets-resolver' => new LoaderComponents\TargetsResolverComponent($packageInfoResolver, true) |
||
126 | )); |
||
127 | |||
128 | $listResolver = new ListResolvers\FilteredListResolver($filters); |
||
129 | |||
130 | $loaderFactory = new \Vaimo\ComposerPatches\Factories\PatchesLoaderFactory($composer); |
||
131 | |||
132 | $repository = $composer->getRepositoryManager()->getLocalRepository(); |
||
133 | |||
134 | $filteredLoader = $loaderFactory->create($filteredPool, $pluginConfig, $isDevMode); |
||
135 | $filteredPatches = $filteredLoader->loadFromPackagesRepository($repository); |
||
136 | |||
137 | $queueGenerator = $this->createQueueGenerator($composer, $pluginConfig, $listResolver); |
||
138 | |||
139 | $repoStateGenerator = $this->createStateGenerator($composer); |
||
140 | |||
141 | $repositoryState = $repoStateGenerator->generate($repository); |
||
142 | |||
143 | $applyQueue = $queueGenerator->generateApplyQueue($filteredPatches, $repositoryState); |
||
144 | $removeQueue = $queueGenerator->generateRemovalQueue($applyQueue, $repositoryState); |
||
145 | $applyQueue = array_map('array_filter', $applyQueue); |
||
146 | |||
147 | $patchListUtils = new \Vaimo\ComposerPatches\Utils\PatchListUtils(); |
||
148 | $patchListUpdater = new \Vaimo\ComposerPatches\Patch\DefinitionList\Updater(); |
||
149 | |||
150 | $filteredPatches = $this->composerFilteredPatchesList( |
||
151 | $filteredPatches, |
||
152 | $applyQueue, |
||
153 | $removeQueue, |
||
154 | $withAffected, |
||
155 | $filters |
||
156 | ); |
||
157 | |||
158 | $patches = array_filter($filteredPatches); |
||
159 | |||
160 | $filterUtils = new \Vaimo\ComposerPatches\Utils\FilterUtils(); |
||
161 | |||
162 | $shouldAddExcludes = $withExcluded |
||
163 | && ( |
||
164 | empty($statusFilters) |
||
165 | || preg_match($filterUtils->composeRegex($statusFilters, '/'), 'excluded') |
||
166 | ); |
||
167 | |||
168 | if ($shouldAddExcludes) { |
||
169 | $unfilteredLoader = $loaderFactory->create($unfilteredPool, $pluginConfig, $isDevMode); |
||
170 | |||
171 | $allPatches = $unfilteredLoader->loadFromPackagesRepository($repository); |
||
172 | |||
173 | $patchesQueue = $listResolver->resolvePatchesQueue($allPatches); |
||
174 | |||
175 | $excludedPatches = $patchListUpdater->updateStatuses( |
||
176 | array_filter($patchListUtils->diffListsByPath($patchesQueue, $filteredPatches)), |
||
177 | 'excluded' |
||
178 | ); |
||
179 | |||
180 | $patches = array_replace_recursive( |
||
181 | $patches, |
||
182 | $patchListUpdater->updateStatuses($excludedPatches, 'excluded') |
||
183 | ); |
||
184 | |||
185 | array_walk($patches, function (array &$group) { |
||
186 | ksort($group); |
||
187 | }, $patches); |
||
188 | } |
||
189 | |||
190 | if ($beBrief) { |
||
191 | $patches = $patchListUpdater->embedInfoToItems($patches, array( |
||
192 | PatchDefinition::LABEL => false, |
||
193 | PatchDefinition::OWNER => false |
||
194 | )); |
||
195 | } |
||
196 | |||
197 | $this->generateOutput($output, $patches); |
||
198 | } |
||
350 |