Conditions | 2 |
Paths | 2 |
Total Lines | 78 |
Code Lines | 51 |
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 |
||
42 | public function create(LoaderComponents $loaderComponentsPool, PluginConfig $pluginConfig, $devMode = false) |
||
43 | { |
||
44 | $installationManager = $this->composer->getInstallationManager(); |
||
45 | |||
46 | $rootPackage = $this->composer->getPackage(); |
||
47 | |||
48 | $loaders = array( |
||
49 | PluginConfig::DEFINITIONS_LIST => new SourceLoaders\PatchList(), |
||
50 | PluginConfig::DEFINITIONS_FILE => new SourceLoaders\PatchesFile($installationManager), |
||
51 | PluginConfig::DEFINITIONS_SEARCH => new SourceLoaders\PatchesSearch( |
||
52 | $installationManager, |
||
53 | $devMode |
||
54 | ) |
||
55 | ); |
||
56 | |||
57 | if ($devMode) { |
||
58 | $loaders = array_replace($loaders, array( |
||
59 | PluginConfig::DEV_DEFINITIONS_LIST => $loaders[PluginConfig::DEFINITIONS_LIST], |
||
60 | PluginConfig::DEV_DEFINITIONS_FILE => $loaders[PluginConfig::DEFINITIONS_FILE] |
||
61 | )); |
||
62 | } |
||
63 | |||
64 | $exploderComponents = array( |
||
65 | new ExploderComponents\LabelVersionConfigComponent(), |
||
66 | new ExploderComponents\VersionConfigComponent(), |
||
67 | new ExploderComponents\VersionRangesConfigComponent(), |
||
68 | new ExploderComponents\ComplexItemComponent(), |
||
69 | new ExploderComponents\SequenceVersionConfigComponent(), |
||
70 | new ExploderComponents\SequenceItemComponent(), |
||
71 | new ExploderComponents\GroupVersionConfigComponent() |
||
72 | ); |
||
73 | |||
74 | $definitionExploder = new Patch\Definition\Exploder($exploderComponents); |
||
75 | |||
76 | $normalizerComponents = array( |
||
77 | new NormalizerComponents\DefaultValuesComponent(), |
||
78 | new NormalizerComponents\BaseComponent(), |
||
79 | new NormalizerComponents\DependencyComponent(), |
||
80 | new NormalizerComponents\PathComponent(), |
||
81 | new NormalizerComponents\BasePathComponent(), |
||
82 | new NormalizerComponents\UrlComponent(), |
||
83 | new NormalizerComponents\SkipComponent(), |
||
84 | new NormalizerComponents\SequenceComponent(), |
||
85 | new NormalizerComponents\PatcherConfigComponent() |
||
86 | ); |
||
87 | |||
88 | $definitionNormalizer = new Patch\Definition\Normalizer($normalizerComponents); |
||
89 | |||
90 | $listNormalizer = new Patch\ListNormalizer( |
||
91 | $definitionExploder, |
||
92 | $definitionNormalizer |
||
93 | ); |
||
94 | |||
95 | $configReaderFactory = new \Vaimo\ComposerPatches\Factories\PatcherConfigReaderFactory( |
||
96 | $this->composer |
||
97 | ); |
||
98 | |||
99 | $configReader = $configReaderFactory->create($pluginConfig); |
||
100 | |||
101 | $patchesCollector = new Patch\Collector( |
||
102 | $listNormalizer, |
||
103 | $configReader, |
||
104 | $loaders |
||
105 | ); |
||
106 | |||
107 | $loaderComponents = $loaderComponentsPool->getList($pluginConfig); |
||
108 | |||
109 | $srcResolverFactory = new \Vaimo\ComposerPatches\Factories\SourcesResolverFactory( |
||
110 | $this->composer |
||
111 | ); |
||
112 | |||
113 | return new \Vaimo\ComposerPatches\Patch\DefinitionList\Loader( |
||
114 | new \Vaimo\ComposerPatches\Package\Collector( |
||
115 | array($rootPackage) |
||
116 | ), |
||
117 | $patchesCollector, |
||
118 | $srcResolverFactory->create($pluginConfig), |
||
119 | $loaderComponents |
||
120 | ); |
||
123 |