| Conditions | 10 |
| Paths | 13 |
| Total Lines | 39 |
| 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 |
||
| 18 | public function handle() |
||
| 19 | { |
||
| 20 | if (! $this->startWarning()) { |
||
| 21 | return null; |
||
| 22 | } |
||
| 23 | |||
| 24 | $psr4 = ComposerJson::readAutoload(); |
||
| 25 | |||
| 26 | $fixedFilesCount = 0; |
||
| 27 | foreach ($psr4 as $psr4Path) { |
||
| 28 | $files = FilePath::getAllPhpFiles($psr4Path); |
||
| 29 | foreach ($files as $file) { |
||
| 30 | $path = $file->getRealPath(); |
||
| 31 | $tokens = token_get_all(file_get_contents($path)); |
||
| 32 | if (empty($tokens) || $tokens[0][0] !== T_OPEN_TAG) { |
||
| 33 | continue; |
||
| 34 | } |
||
| 35 | |||
| 36 | try { |
||
| 37 | $tokens = SyntaxNormalizer::normalizeSyntax($tokens, true); |
||
| 38 | } catch (\Exception $e) { |
||
| 39 | self::requestIssue($path); |
||
| 40 | continue; |
||
| 41 | } |
||
| 42 | |||
| 43 | if (! SyntaxNormalizer::$hasChange || ! $this->getConfirm($path)) { |
||
| 44 | continue; |
||
| 45 | } |
||
| 46 | |||
| 47 | Refactor::saveTokens($path, $tokens, $this->option('test')); |
||
| 48 | |||
| 49 | $fixedFilesCount++; |
||
| 50 | } |
||
| 51 | } |
||
| 52 | |||
| 53 | $this->printFinalMsg($fixedFilesCount); |
||
| 54 | |||
| 55 | return app(ErrorPrinter::class)->hasErrors() ? 1 : 0; |
||
| 56 | } |
||
| 57 | |||
| 91 |