Conditions | 3 |
Paths | 4 |
Total Lines | 77 |
Code Lines | 52 |
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 |
||
41 | public function create(PluginConfig $pluginConfig, ListResolver $listResolver, OutputStrategy $outputStrategy) |
||
42 | { |
||
43 | $installer = $this->composer->getInstallationManager(); |
||
44 | $downloader = $this->composer->getDownloadManager(); |
||
45 | |||
46 | $eventDispatcher = $this->composer->getEventDispatcher(); |
||
47 | $rootPackage = $this->composer->getPackage(); |
||
48 | $composerConfig = $this->composer->getConfig(); |
||
49 | |||
50 | $output = $this->logger->getOutputInstance(); |
||
51 | |||
52 | $vendorRoot = $composerConfig->get(\Vaimo\ComposerPatches\Composer\ConfigKeys::VENDOR_DIR); |
||
53 | |||
54 | $packageInfoResolver = new \Vaimo\ComposerPatches\Package\InfoResolver( |
||
55 | $installer, |
||
56 | $vendorRoot |
||
57 | ); |
||
58 | |||
59 | $failureHandler = $pluginConfig->shouldExitOnFirstFailure() |
||
60 | ? new FailureHandlers\FatalHandler() |
||
61 | : new FailureHandlers\GracefulHandler($this->logger); |
||
62 | |||
63 | $patchFileApplier = new \Vaimo\ComposerPatches\Patch\File\Applier( |
||
64 | $this->logger, |
||
65 | $pluginConfig->getPatcherConfig() |
||
66 | ); |
||
67 | |||
68 | $patchDetailsLogger = new \Vaimo\ComposerPatches\Package\PatchApplier\InfoLogger($this->logger); |
||
69 | |||
70 | $patchProcessor = new \Vaimo\ComposerPatches\Package\PatchApplier\ItemProcessor( |
||
71 | $eventDispatcher, |
||
72 | $packageInfoResolver, |
||
73 | $failureHandler, |
||
74 | $patchFileApplier, |
||
75 | $this->logger |
||
76 | ); |
||
77 | |||
78 | $packagePatchApplier = new \Vaimo\ComposerPatches\Package\PatchApplier( |
||
79 | $patchProcessor, |
||
80 | $patchDetailsLogger, |
||
81 | $outputStrategy, |
||
82 | $this->logger |
||
83 | ); |
||
84 | |||
85 | $packageCollector = new \Vaimo\ComposerPatches\Package\Collector( |
||
86 | array($rootPackage) |
||
87 | ); |
||
88 | |||
89 | $stateAnalyser = new \Vaimo\ComposerPatches\Repository\State\Analyser(); |
||
90 | |||
91 | $queueGenerator = new \Vaimo\ComposerPatches\Repository\PatchesApplier\QueueGenerator( |
||
92 | $listResolver, |
||
93 | $stateAnalyser |
||
94 | ); |
||
95 | |||
96 | $patcherStateManager = new \Vaimo\ComposerPatches\Managers\PatcherStateManager(); |
||
97 | |||
98 | $packageResetStrategy = $pluginConfig->shouldForcePackageReset() |
||
99 | ? new Strategies\Package\ForcedResetStrategy() |
||
100 | : new Strategies\Package\DefaultResetStrategy($installer, $downloader); |
||
101 | |||
102 | $repositoryManager = new \Vaimo\ComposerPatches\Managers\RepositoryManager( |
||
103 | $installer, |
||
104 | $packageResetStrategy, |
||
105 | new \Vaimo\ComposerPatches\Console\Silencer($output) |
||
106 | ); |
||
107 | |||
108 | return new \Vaimo\ComposerPatches\Repository\PatchesApplier( |
||
109 | $this->composer, |
||
110 | $packageCollector, |
||
111 | $repositoryManager, |
||
112 | $packagePatchApplier, |
||
113 | $queueGenerator, |
||
114 | $patcherStateManager, |
||
115 | $patchDetailsLogger, |
||
116 | $outputStrategy, |
||
117 | $this->logger |
||
118 | ); |
||
121 |