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