| Conditions | 4 |
| Paths | 8 |
| Total Lines | 57 |
| Code Lines | 44 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 11 | ||
| Bugs | 1 | Features | 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 |
||
| 32 | public function runActualTask($params = []): ?string |
||
| 33 | { |
||
| 34 | $webRoot = $this->mu()->getWebRootDirLocation(); |
||
| 35 | $localInstall = (bool) PHP2CommandLineSingleton::commandExists('sake-ling-all'); |
||
| 36 | $commandAdd = ''; |
||
| 37 | if ($localInstall) { |
||
| 38 | $commandAdd = 'vendor/bin/'; |
||
| 39 | Composer::inst($this->mu()) |
||
| 40 | ->RequireDev( |
||
| 41 | 'sunnysideup/easy-coding-standards', |
||
| 42 | 'dev-master', |
||
| 43 | $this->composerOptions |
||
| 44 | ); |
||
| 45 | } |
||
| 46 | |||
| 47 | //1. apply |
||
| 48 | foreach ($this->mu()->findNameSpaceAndCodeDirs() as $baseNameSpace => $codeDir) { |
||
| 49 | $knownIssuesFileName = $codeDir . '/' . $this->lintingIssuesFileName; |
||
| 50 | $relativeDir = str_replace($webRoot, '', $codeDir); |
||
| 51 | $relativeDir = ltrim($relativeDir, '/'); |
||
| 52 | FileSystemFixes::inst($this->mu()) |
||
| 53 | ->removeDirOrFile($knownIssuesFileName); |
||
| 54 | $this->mu()->execMe( |
||
| 55 | $webRoot, |
||
| 56 | $commandAdd . 'sake-lint-all ' . $relativeDir, |
||
| 57 | 'Apply easy coding standards to ' . $relativeDir . ' (' . $baseNameSpace . ')', |
||
| 58 | false |
||
| 59 | ); |
||
| 60 | $this->mu()->execMe( |
||
| 61 | $webRoot, |
||
| 62 | $commandAdd . 'sake-lint-all ' . $relativeDir, |
||
| 63 | 'Apply easy coding standards a second time ' . $relativeDir . ' (' . $baseNameSpace . ')', |
||
| 64 | false |
||
| 65 | ); |
||
| 66 | $this->mu()->execMe( |
||
| 67 | $webRoot, |
||
| 68 | $commandAdd . 'sake-lint-all ' . $relativeDir . ' > ' . $knownIssuesFileName, |
||
| 69 | 'Apply easy coding standards a third time ' . $relativeDir . ' (' . $baseNameSpace . ') and saving to ' . $knownIssuesFileName, |
||
| 70 | false |
||
| 71 | ); |
||
| 72 | $this->mu()->execMe( |
||
| 73 | $webRoot, |
||
| 74 | $commandAdd . 'sslint-stan ' . $relativeDir . ' >> ' . $knownIssuesFileName, |
||
| 75 | 'Apply phpstan. to ' . $relativeDir . ' (' . $baseNameSpace . ') and saving to: ' . $knownIssuesFileName, |
||
| 76 | false |
||
| 77 | ); |
||
| 78 | } |
||
| 79 | if ($localInstall) { |
||
| 80 | $commandAdd = 'vendor/bin/'; |
||
| 81 | Composer::inst($this->mu()) |
||
| 82 | ->RemoveDev( |
||
| 83 | 'sunnysideup/easy-coding-standards', |
||
| 84 | 'dev-master', |
||
| 85 | $this->composerOptions |
||
| 86 | ); |
||
| 87 | } |
||
| 88 | return null; |
||
| 89 | } |
||
| 96 |