Conditions | 13 |
Paths | 160 |
Total Lines | 73 |
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 |
||
53 | public static function printCheck($checkPassed, Printer $printer, RequirementCollection $requirements): void |
||
54 | { |
||
55 | if (false === $checkPassed && IO::VERBOSITY_VERY_VERBOSE > $printer->getVerbosity()) { |
||
56 | // Override the default verbosity to output errors regardless of the verbosity asked by the user |
||
57 | $printer->setVerbosity(IO::VERBOSITY_VERY_VERBOSE); |
||
58 | } |
||
59 | |||
60 | $verbosity = IO::VERBOSITY_VERY_VERBOSE; |
||
61 | |||
62 | $iniPath = $requirements->getPhpIniPath(); |
||
63 | |||
64 | $printer->title('Box Requirements Checker', $verbosity); |
||
65 | |||
66 | $printer->printv('> Using PHP ', $verbosity); |
||
67 | $printer->printvln(PHP_VERSION, $verbosity, 'green'); |
||
68 | |||
69 | if ($iniPath) { |
||
70 | $printer->printvln('> PHP is using the following php.ini file:', $verbosity); |
||
71 | $printer->printvln(' '.$iniPath, $verbosity, 'green'); |
||
72 | } else { |
||
73 | $printer->printvln('> PHP is not using any php.ini file.', $verbosity, 'yellow'); |
||
74 | } |
||
75 | |||
76 | $printer->printvln('', $verbosity); |
||
77 | |||
78 | if (count($requirements) > 0) { |
||
79 | $printer->printvln('> Checking Box requirements:', $verbosity); |
||
80 | $printer->printv(' ', $verbosity); |
||
81 | } else { |
||
82 | $printer->printvln('> No requirements found.', $verbosity); |
||
83 | } |
||
84 | |||
85 | $errorMessages = []; |
||
86 | |||
87 | foreach ($requirements->getRequirements() as $requirement) { |
||
88 | if ($errorMessage = $printer->getRequirementErrorMessage($requirement)) { |
||
89 | if (IO::VERBOSITY_DEBUG === $printer->getVerbosity()) { |
||
90 | $printer->printvln('✘ '.$requirement->getTestMessage(), IO::VERBOSITY_DEBUG, 'red'); |
||
91 | $printer->printv(' ', IO::VERBOSITY_DEBUG); |
||
92 | $errorMessages[] = $errorMessage; |
||
93 | } else { |
||
94 | $printer->printv('E', $verbosity, 'red'); |
||
95 | $errorMessages[] = $errorMessage; |
||
96 | } |
||
97 | |||
98 | continue; |
||
99 | } |
||
100 | |||
101 | if (IO::VERBOSITY_DEBUG === $printer->getVerbosity()) { |
||
102 | $printer->printvln('✔ '.$requirement->getTestMessage(), IO::VERBOSITY_DEBUG, 'green'); |
||
103 | $printer->printv(' ', IO::VERBOSITY_DEBUG); |
||
104 | } else { |
||
105 | $printer->printv('.', $verbosity, 'green'); |
||
106 | } |
||
107 | } |
||
108 | |||
109 | if (IO::VERBOSITY_DEBUG !== $printer->getVerbosity() && count($requirements) > 0) { |
||
110 | $printer->printvln('', $verbosity); |
||
111 | } |
||
112 | |||
113 | if ($requirements->evaluateRequirements()) { |
||
114 | $printer->block('OK', 'Your system is ready to run the application.', $verbosity, 'success'); |
||
115 | } else { |
||
116 | $printer->block('ERROR', 'Your system is not ready to run the application.', $verbosity, 'error'); |
||
117 | |||
118 | $printer->title('Fix the following mandatory requirements:', $verbosity, 'red'); |
||
119 | |||
120 | foreach ($errorMessages as $errorMessage) { |
||
121 | $printer->printv(' * '.$errorMessage, $verbosity); |
||
122 | } |
||
123 | } |
||
124 | |||
125 | $printer->printvln('', $verbosity); |
||
126 | } |
||
179 |