Conditions | 14 |
Paths | 98 |
Total Lines | 60 |
Code Lines | 38 |
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 |
||
49 | |||
50 | $this->mu()->execMe( |
||
51 | $this->mu()->getGitRootDir(), |
||
52 | 'composer update -vvv --no-interaction', |
||
53 | 'run composer update', |
||
54 | false |
||
55 | ); |
||
56 | return null; |
||
57 | } |
||
58 | |||
59 | |||
60 | protected function moveToTmpVar() |
||
61 | { |
||
62 | $composerData = ComposerJsonFixes::inst($this->mu())->getJSON( |
||
63 | $this->mu()->getGitRootDir() |
||
64 | ); |
||
65 | foreach (['require', 'require-dev'] as $section) { |
||
66 | $tmpSection = $section.$this->appendixToKey; |
||
67 | // move all |
||
68 | if(! empty($composerData[$section])) { |
||
69 | $composerData[$tmpSection] = $composerData[$section]; |
||
70 | unset($composerData[$section]); |
||
71 | } |
||
72 | // move the keeps back! |
||
73 | foreach($this->alwaysKeepArray as $package) { |
||
74 | if(isset($composerData[$tmpSection][$package])) { |
||
75 | $composerData[$section][$package] = $composerData[$tmpSection][$package]; |
||
76 | unset($composerData[$tmpSection][$package]); |
||
77 | } |
||
78 | } |
||
79 | } |
||
80 | ComposerJsonFixes::inst($this->mu())->setJSON( |
||
81 | $this->mu()->getGitRootDir(), |
||
82 | $composerData |
||
83 | ); |
||
84 | } |
||
85 | |||
86 | |||
87 | protected function testEachRequirement() |
||
88 | { |
||
89 | $composerData = ComposerJsonFixes::inst($this->mu())->getJSON( |
||
90 | $this->mu()->getGitRootDir() |
||
91 | ); |
||
92 | foreach (['require', 'require-dev'] as $section) { |
||
93 | $tmpSection = $section.$this->appendixToKey; |
||
94 | if (isset($composerData[$tmpSection]) && is_array($composerData[$tmpSection]) && count($composerData[$tmpSection])) { |
||
95 | foreach ($composerData[$tmpSection] as $package => $version) { |
||
96 | |||
97 | $this->mu()->colourPrint('trying to add '.$package.':'.$version, 'yellow', 1); |
||
98 | |||
99 | // Attempt to require the package |
||
100 | $output = ''; |
||
101 | exec("composer require $package:$version --no-update", $output, $returnVar); |
||
102 | if ($returnVar !== 0) { |
||
103 | $this->mu()->colourPrint("$package:$version could not be added. Skipping...", 'red', 1); |
||
104 | $this->updateComposerJson($section, $package, $version, 'remove'); |
||
105 | // Skip adding to suggest or removing since it's being processed dynamically |
||
106 | } else { |
||
107 | // If require was successful, update composer |
||
108 | $output = ''; |
||
109 | exec('composer update', $output, $updateReturnVar); |
||
157 |