Conditions | 13 |
Paths | 26 |
Total Lines | 26 |
Code Lines | 15 |
Lines | 0 |
Ratio | 0 % |
Changes | 2 | ||
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 |
||
32 | public function validate($manifest) |
||
33 | { |
||
34 | $errors = array(); |
||
35 | |||
36 | if (isset($manifest['config']['sort-packages']) && $manifest['config']['sort-packages']) { |
||
37 | foreach (array('require', 'require-dev', 'conflict', 'replace', 'provide', 'suggest') as $linksSection) { |
||
38 | if (array_key_exists($linksSection, $manifest) && !$this->packagesAreSorted($manifest[$linksSection])) { |
||
39 | array_push($errors, 'Links under '.$linksSection.' section are not sorted.'); |
||
40 | } |
||
41 | } |
||
42 | } |
||
43 | |||
44 | if (true === $this->config['php'] && |
||
45 | (array_key_exists('require-dev', $manifest) || array_key_exists('require', $manifest))) { |
||
46 | $isOnRequireDev = array_key_exists('require-dev', $manifest) && array_key_exists('php', $manifest['require-dev']); |
||
47 | $isOnRequire = array_key_exists('require', $manifest) && array_key_exists('php', $manifest['require']); |
||
48 | |||
49 | if ($isOnRequireDev) { |
||
50 | array_push($errors, 'PHP requirement should be in the require section, not in the require-dev section.'); |
||
51 | } elseif (!$isOnRequire) { |
||
52 | array_push($errors, 'You must specifiy the PHP requirement.'); |
||
53 | } |
||
54 | } |
||
55 | |||
56 | return $errors; |
||
57 | } |
||
58 | |||
82 |