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