Conditions | 11 |
Paths | 10 |
Total Lines | 25 |
Code Lines | 21 |
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 |
||
54 | public function getParser($fileName) { |
||
55 | $parser = null; |
||
56 | |||
57 | if (strpos($fileName, '/') === strlen($fileName) - 1) { |
||
58 | $parser = $this->getByType(self::FOLDER_PARSER); |
||
59 | } else if (strpos($fileName, '.json') !== false) { |
||
60 | $parser = $this->getByType(self::JSON_PARSER); |
||
61 | } else if (strpos($fileName, '.md') !== false) { |
||
62 | $parser = $this->getByType(self::MARKDOWN_PARSER); |
||
63 | } else if (strpos($fileName, '.yml') !== false) { |
||
64 | $parser = $this->getByType(self::YAML_PARSER); |
||
65 | } else if (strpos($fileName, '.jpg') !== false) { |
||
66 | $parser = $this->getByType(self::IMAGE_PARSER); |
||
67 | } else if (strpos($fileName, '.png') !== false) { |
||
68 | $parser = $this->getByType(self::IMAGE_PARSER); |
||
69 | } else if (strpos($fileName, '.css') !== false) { |
||
70 | $parser = $this->getByType(self::CSS_PARSER); |
||
71 | } else if (strpos($fileName, '.js') !== false) { |
||
72 | $parser = $this->getByType(self::JS_PARSER); |
||
73 | } else if (strpos($fileName, '.scss') !== false || strpos($fileName, '.sass') !== false) { |
||
74 | $parser = $this->getByType(self::SASS_PARSER); |
||
75 | } |
||
76 | |||
77 | return $parser; |
||
78 | } |
||
79 | |||
128 |