| Conditions | 4 |
| Paths | 3 |
| Total Lines | 68 |
| Code Lines | 52 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 4 | ||
| Bugs | 0 | 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 |
||
| 41 | public function runActualTask($params = []): ?string |
||
| 42 | { |
||
| 43 | $webRoot = $this->mu()->getWebRootDirLocation(); |
||
| 44 | if (PHP2CommandLineSingleton::commandExists('sslint-compat')) { |
||
| 45 | foreach ($this->mu()->findNameSpaceAndCodeDirs() as $codeDir) { |
||
| 46 | // $file = str_replace('\\', '-', $baseNameSpace); |
||
| 47 | $this->mu()->execMe( |
||
| 48 | $webRoot, |
||
| 49 | 'sslint-compat ' . $codeDir, |
||
| 50 | 'Running PHP Compatibility Check in: ' . $codeDir, |
||
| 51 | false |
||
| 52 | ); |
||
| 53 | } |
||
| 54 | } else { |
||
| 55 | Composer::inst($this->mu()) |
||
| 56 | ->RequireDev( |
||
| 57 | 'squizlabs/php_codesniffer', |
||
| 58 | '', |
||
| 59 | $this->composerOptions |
||
| 60 | ) |
||
| 61 | ->RequireDev( |
||
| 62 | 'phpcompatibility/php-compatibility', |
||
| 63 | '', |
||
| 64 | $this->composerOptions |
||
| 65 | ); |
||
| 66 | |||
| 67 | $this->mu()->execMe( |
||
| 68 | $webRoot, |
||
| 69 | './vendor/bin/phpcs --config-set installed_paths vendor/phpcompatibility/php-compatibility', |
||
| 70 | 'Adding php compatability info', |
||
| 71 | false |
||
| 72 | ); |
||
| 73 | $this->mu()->execMe( |
||
| 74 | $webRoot, |
||
| 75 | './vendor/bin/phpcs --config-set colors 1', |
||
| 76 | 'Adding colour', |
||
| 77 | false |
||
| 78 | ); |
||
| 79 | $this->mu()->execMe( |
||
| 80 | $webRoot, |
||
| 81 | './vendor/bin/phpcs --config-set severity 1', |
||
| 82 | 'Showing all errors', |
||
| 83 | false |
||
| 84 | ); |
||
| 85 | $this->mu()->execMe( |
||
| 86 | $webRoot, |
||
| 87 | './vendor/bin/phpcs --config-show', |
||
| 88 | 'Showing all errors', |
||
| 89 | false |
||
| 90 | ); |
||
| 91 | foreach ($this->mu()->findNameSpaceAndCodeDirs() as $codeDir) { |
||
| 92 | // $file = str_replace('\\', '-', $baseNameSpace); |
||
| 93 | $this->mu()->execMe( |
||
| 94 | $webRoot, |
||
| 95 | './vendor/bin/phpcs' . |
||
| 96 | ' -p ' . $codeDir . |
||
| 97 | ' --standard=PHPCompatibility' . |
||
| 98 | ' --extensions=php ' . |
||
| 99 | ' --runtime-set testVersion ' . $this->phpVersion, |
||
| 100 | 'Running PHP Compatibility Check in: ' . $codeDir, |
||
| 101 | false |
||
| 102 | ); |
||
| 103 | } |
||
| 104 | Composer::inst($this->mu()) |
||
| 105 | ->Remove('squizlabs/php_codesniffer', true) |
||
| 106 | ->Remove('phpcompatibility/php-compatibility', true); |
||
| 107 | } |
||
| 108 | return null; |
||
| 109 | } |
||
| 116 |