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