Conditions | 8 |
Paths | 20 |
Total Lines | 54 |
Code Lines | 28 |
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 |
||
92 | private function resolveComparisonResults(array $patchConstraints, array $packages, array $rootRequires) |
||
93 | { |
||
94 | $comparisonResults = array(); |
||
95 | |||
96 | foreach ($patchConstraints as $constraintTarget => $version) { |
||
97 | if (!isset($packages[$constraintTarget])) { |
||
98 | continue; |
||
99 | } |
||
100 | |||
101 | $package = $packages[$constraintTarget]; |
||
102 | |||
103 | $packageVersion = $package->getVersion(); |
||
104 | $packageVersions = array($package->getVersion()); |
||
105 | |||
106 | if (isset($rootRequires[$constraintTarget])) { |
||
107 | /** @var \Composer\Package\CompletePackageInterface $targetRootPackage */ |
||
108 | $targetRootPackage = $rootRequires[$constraintTarget]; |
||
109 | |||
110 | $prettyVersion = $this->packageUtils->getPrettyVersion($targetRootPackage); |
||
111 | |||
112 | $matches = array(); |
||
113 | preg_match('/.* as (.*)$/', $prettyVersion, $matches); |
||
114 | |||
115 | if (isset($matches[1])) { |
||
116 | $packageVersions[] = $matches[1]; |
||
117 | } |
||
118 | } |
||
119 | |||
120 | if ($this->constraintUtils->isDevConstraint($packageVersion)) { |
||
121 | $definedVersion = $this->configExtractor->getConfig( |
||
122 | $package, |
||
123 | 'version' |
||
124 | ); |
||
125 | |||
126 | $packageVersions[] = $definedVersion; |
||
127 | } |
||
128 | |||
129 | $matchResult = false; |
||
130 | |||
131 | foreach (array_filter($packageVersions) as $packageVersion) { |
||
132 | $packageConstraint = $this->versionParser->parseConstraints($packageVersion); |
||
133 | $patchConstraint = $this->versionParser->parseConstraints($version); |
||
134 | |||
135 | $matchResult = $patchConstraint->matches($packageConstraint); |
||
136 | |||
137 | if ($matchResult) { |
||
138 | break; |
||
139 | } |
||
140 | } |
||
141 | |||
142 | $comparisonResults[] = $matchResult; |
||
143 | } |
||
144 | |||
145 | return $comparisonResults; |
||
146 | } |
||
148 |