| Conditions | 6 |
| Paths | 16 |
| Total Lines | 81 |
| Code Lines | 59 |
| 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 |
||
| 56 | public function getList(PluginConfig $pluginConfig) |
||
| 57 | { |
||
| 58 | $patcherConfig = $pluginConfig->getPatcherConfig(); |
||
| 59 | $composer = $this->composerContext->getLocalComposer(); |
||
| 60 | $composerConfig = clone $composer->getConfig(); |
||
| 61 | |||
| 62 | $composerConfig->merge(array( |
||
| 63 | 'config' => array('secure-http' => $patcherConfig[PluginConfig::PATCHER_SECURE_HTTP]) |
||
| 64 | )); |
||
| 65 | |||
| 66 | $rootPackage = $composer->getPackage(); |
||
| 67 | $extra = $rootPackage->getExtra(); |
||
| 68 | |||
| 69 | if (isset($extra['excluded-patches']) && !isset($extra[PluginConfig::EXCLUDED_PATCHES])) { |
||
| 70 | $extra[PluginConfig::EXCLUDED_PATCHES] = $extra['excluded-patches']; |
||
| 71 | } |
||
| 72 | |||
| 73 | $excludes = isset($extra[PluginConfig::EXCLUDED_PATCHES]) |
||
| 74 | ? $extra[PluginConfig::EXCLUDED_PATCHES] |
||
| 75 | : array(); |
||
| 76 | |||
| 77 | $installationManager = $composer->getInstallationManager(); |
||
| 78 | $cache = null; |
||
| 79 | |||
| 80 | if ($composerConfig->get('cache-files-ttl') > 0) { |
||
| 81 | $cache = new \Composer\Cache( |
||
| 82 | $this->appIO, |
||
| 83 | $composerConfig->get('cache-files-dir'), |
||
| 84 | 'a-z0-9_./' |
||
| 85 | ); |
||
| 86 | } |
||
| 87 | |||
| 88 | $composerDependencies = new \Vaimo\ComposerPatches\Compatibility\DependenciesFactory(); |
||
| 89 | $fileDownloader = $composerDependencies->createFileDownloader( |
||
| 90 | $this->appIO, |
||
| 91 | $composer, |
||
| 92 | $composerConfig, |
||
| 93 | $cache |
||
| 94 | ); |
||
| 95 | |||
| 96 | $vendorRoot = $composerConfig->get(\Vaimo\ComposerPatches\Composer\ConfigKeys::VENDOR_DIR); |
||
| 97 | $packageInfoResolver = new \Vaimo\ComposerPatches\Package\InfoResolver( |
||
| 98 | $installationManager, |
||
| 99 | $vendorRoot |
||
| 100 | ); |
||
| 101 | $configExtractor = new \Vaimo\ComposerPatches\Package\ConfigExtractors\VendorConfigExtractor( |
||
| 102 | $packageInfoResolver |
||
| 103 | ); |
||
| 104 | $composerConfigUtils = new \Vaimo\ComposerPatches\Utils\ComposerConfigUtils(); |
||
| 105 | $platformPackages = $composerConfigUtils->resolveConstraintPackages($composerConfig); |
||
| 106 | $packageResolver = new \Vaimo\ComposerPatches\Composer\Plugin\PackageResolver( |
||
| 107 | array($composer->getPackage()) |
||
| 108 | ); |
||
| 109 | $packages = $this->composerContext->getActivePackages(); |
||
| 110 | $pluginPackage = $packageResolver->resolveForNamespace($packages, __NAMESPACE__); |
||
| 111 | $consoleSilencer = new \Vaimo\ComposerPatches\Console\Silencer($this->appIO); |
||
| 112 | |||
| 113 | $defaults = array( |
||
| 114 | 'bundle' => new LoaderComponents\BundleComponent($rootPackage), |
||
| 115 | 'global-exclude' => $excludes ? new LoaderComponents\GlobalExcludeComponent($excludes) : false, |
||
| 116 | 'local-exclude' => new LoaderComponents\LocalExcludeComponent(), |
||
| 117 | 'root-patch' => new LoaderComponents\RootPatchComponent($rootPackage), |
||
| 118 | 'path-normalizer' => new LoaderComponents\PathNormalizerComponent($packageInfoResolver), |
||
| 119 | 'platform' => new LoaderComponents\PlatformComponent($platformPackages), |
||
| 120 | 'constraints' => new LoaderComponents\ConstraintsComponent($configExtractor), |
||
| 121 | 'downloader' => new LoaderComponents\DownloaderComponent( |
||
| 122 | $composer, |
||
| 123 | $pluginPackage, |
||
| 124 | $fileDownloader, |
||
| 125 | $consoleSilencer, |
||
| 126 | $vendorRoot, |
||
| 127 | $this->gracefulMode |
||
| 128 | ), |
||
| 129 | 'validator' => new LoaderComponents\ValidatorComponent(), |
||
| 130 | 'targets-resolver' => new LoaderComponents\TargetsResolverComponent($packageInfoResolver), |
||
| 131 | 'merger' => new LoaderComponents\MergerComponent(), |
||
| 132 | 'sorter' => new LoaderComponents\SorterComponent() |
||
| 133 | ); |
||
| 134 | |||
| 135 | return array_values( |
||
| 136 | array_filter(array_replace($defaults, $this->components)) |
||
| 137 | ); |
||
| 145 |