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