| Conditions | 13 |
| Paths | 160 |
| Total Lines | 56 |
| Code Lines | 44 |
| 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 |
||
| 21 | public static function printCheck($checkPassed, Printer $printer, RequirementCollection $requirements) : void |
||
| 22 | { |
||
| 23 | if (\false === $checkPassed && IO::VERBOSITY_VERY_VERBOSE > $printer->getVerbosity()) { |
||
| 24 | $printer->setVerbosity(IO::VERBOSITY_VERY_VERBOSE); |
||
| 25 | } |
||
| 26 | $verbosity = IO::VERBOSITY_VERY_VERBOSE; |
||
| 27 | $iniPath = $requirements->getPhpIniPath(); |
||
| 28 | $printer->title('Box Requirements Checker', $verbosity); |
||
| 29 | $printer->printv('> Using PHP ', $verbosity); |
||
| 30 | $printer->printvln(\PHP_VERSION, $verbosity, 'green'); |
||
| 31 | if ($iniPath) { |
||
| 32 | $printer->printvln('> PHP is using the following php.ini file:', $verbosity); |
||
| 33 | $printer->printvln(' ' . $iniPath, $verbosity, 'green'); |
||
|
|
|||
| 34 | } else { |
||
| 35 | $printer->printvln('> PHP is not using any php.ini file.', $verbosity, 'yellow'); |
||
| 36 | } |
||
| 37 | $printer->printvln('', $verbosity); |
||
| 38 | if (count($requirements) > 0) { |
||
| 39 | $printer->printvln('> Checking Box requirements:', $verbosity); |
||
| 40 | $printer->printv(' ', $verbosity); |
||
| 41 | } else { |
||
| 42 | $printer->printvln('> No requirements found.', $verbosity); |
||
| 43 | } |
||
| 44 | $errorMessages = []; |
||
| 45 | foreach ($requirements->getRequirements() as $requirement) { |
||
| 46 | if ($errorMessage = $printer->getRequirementErrorMessage($requirement)) { |
||
| 47 | if (IO::VERBOSITY_DEBUG === $printer->getVerbosity()) { |
||
| 48 | $printer->printvln('✘ ' . $requirement->getTestMessage(), IO::VERBOSITY_DEBUG, 'red'); |
||
| 49 | $printer->printv(' ', IO::VERBOSITY_DEBUG); |
||
| 50 | $errorMessages[] = $errorMessage; |
||
| 51 | } else { |
||
| 52 | $printer->printv('E', $verbosity, 'red'); |
||
| 53 | $errorMessages[] = $errorMessage; |
||
| 54 | } |
||
| 55 | continue; |
||
| 56 | } |
||
| 57 | if (IO::VERBOSITY_DEBUG === $printer->getVerbosity()) { |
||
| 58 | $printer->printvln('✔ ' . $requirement->getTestMessage(), IO::VERBOSITY_DEBUG, 'green'); |
||
| 59 | $printer->printv(' ', IO::VERBOSITY_DEBUG); |
||
| 60 | } else { |
||
| 61 | $printer->printv('.', $verbosity, 'green'); |
||
| 62 | } |
||
| 63 | } |
||
| 64 | if (IO::VERBOSITY_DEBUG !== $printer->getVerbosity() && count($requirements) > 0) { |
||
| 65 | $printer->printvln('', $verbosity); |
||
| 66 | } |
||
| 67 | if ($requirements->evaluateRequirements()) { |
||
| 68 | $printer->block('OK', 'Your system is ready to run the application.', $verbosity, 'success'); |
||
| 69 | } else { |
||
| 70 | $printer->block('ERROR', 'Your system is not ready to run the application.', $verbosity, 'error'); |
||
| 71 | $printer->title('Fix the following mandatory requirements:', $verbosity, 'red'); |
||
| 72 | foreach ($errorMessages as $errorMessage) { |
||
| 73 | $printer->printv(' * ' . $errorMessage, $verbosity); |
||
| 74 | } |
||
| 75 | } |
||
| 76 | $printer->printvln('', $verbosity); |
||
| 77 | } |
||
| 104 |