| Conditions | 16 | 
| Paths | 50 | 
| Total Lines | 81 | 
| Code Lines | 42 | 
| 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 | ||
| 129 | */ | ||
| 130 | protected function isAllowedType($type) | ||
| 131 |     { | ||
| 132 | $allowedTypes = (array) Config::inst()->get(UpdatePackageInfo::class, 'allowed_types'); | ||
| 133 | |||
| 134 | return in_array($type, $allowedTypes); | ||
| 135 | } | ||
| 136 | |||
| 137 | /** | ||
| 138 | * prints a message during the run of the task | ||
| 139 | * | ||
| 140 | * @param string $text | ||
| 141 | */ | ||
| 142 | protected function message($text) | ||
| 143 |     { | ||
| 144 |         if (!Director::is_cli()) { | ||
| 145 | $text = '<p>' . $text . '</p>'; | ||
| 146 | } | ||
| 147 | |||
| 148 | echo $text . PHP_EOL; | ||
| 149 | } | ||
| 150 | |||
| 151 | /** | ||
| 152 | * @param ComposerLoader $composerLoader | ||
| 153 | * @return $this | ||
| 154 | */ | ||
| 155 | public function setComposerLoader(ComposerLoader $composerLoader) | ||
| 156 |     { | ||
| 157 | $this->composerLoader = $composerLoader; | ||
| 158 | return $this; | ||
| 159 | } | ||
| 160 | |||
| 161 | /** | ||
| 162 | * @return ComposerLoader | ||
| 163 | */ | ||
| 164 | public function getComposerLoader() | ||
| 165 |     { | ||
| 166 | return $this->composerLoader; | ||
| 167 | } | ||
| 168 | |||
| 169 | /** | ||
| 170 | * @param UpdateChecker $updateChecker | ||
| 171 | * @return $this | ||
| 172 | */ | ||
| 173 | public function setUpdateChecker(UpdateChecker $updateChecker) | ||
| 174 |     { | ||
| 175 | $this->updateChecker = $updateChecker; | ||
| 176 | return $this; | ||
| 177 | } | ||
| 178 | |||
| 179 | /** | ||
| 180 | * @return UpdateChecker | ||
| 181 | */ | ||
| 182 | public function getUpdateChecker() | ||
| 183 |     { | ||
| 184 | return $this->updateChecker; | ||
| 185 | } | ||
| 186 | } | ||
| 187 | 
You can fix this by adding a namespace to your class:
When choosing a vendor namespace, try to pick something that is not too generic to avoid conflicts with other libraries.