| Conditions | 12 |
| Paths | 11 |
| Total Lines | 43 |
| Code Lines | 22 |
| 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 |
||
| 60 | } |
||
| 61 | |||
| 62 | if (strpos($fileName, '.jpg') !== false) { |
||
| 63 | return $this->getByType(self::EXTENSION_IMG); |
||
| 64 | } |
||
| 65 | |||
| 66 | if (strpos($fileName, '.png') !== false) { |
||
| 67 | return $this->getByType(self::EXTENSION_IMG); |
||
| 68 | } |
||
| 69 | |||
| 70 | if (strpos($fileName, '.css') !== false) { |
||
| 71 | return $this->getByType(self::EXTENSION_CSS); |
||
| 72 | } |
||
| 73 | |||
| 74 | if (strpos($fileName, '.js') !== false) { |
||
| 75 | return $this->getByType(self::EXTENSION_JS); |
||
| 76 | } |
||
| 77 | |||
| 78 | if (strpos($fileName, '.scss') !== false || strpos($fileName, '.sass') !== false) { |
||
| 79 | return $this->getByType(self::EXTENSION_SASS); |
||
| 80 | } |
||
| 81 | |||
| 82 | return $this->getByType(self::PARSER_DEFAULT); |
||
| 83 | } |
||
| 84 | |||
| 85 | /** |
||
| 86 | * @param string $type |
||
| 87 | * |
||
| 88 | * @return mixed |
||
| 89 | */ |
||
| 90 | public function getByType($type) : Parser { |
||
| 91 | switch ($type) { |
||
| 92 | case self::EXTENSION_IMG: |
||
| 93 | return $this->container->get('parser.image'); |
||
| 94 | case self::EXTENSION_FOLDER: |
||
| 95 | return $this->container->get('parser.folder'); |
||
| 96 | case self::EXTENSION_MD: |
||
| 97 | return $this->container->get('parser.markdown'); |
||
| 98 | case self::EXTENSION_JSON: |
||
| 99 | return $this->container->get('parser.json'); |
||
| 100 | case self::EXTENSION_YML: |
||
| 101 | case self::EXTENSION_YAML: |
||
| 102 | return $this->container->get('parser.yaml'); |
||
| 103 | case self::EXTENSION_JS: |
||
| 116 |