Conditions | 20 |
Paths | > 20000 |
Total Lines | 59 |
Code Lines | 40 |
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 |
||
109 | protected function checkPHPExtensions(SymfonyStyle $io, $only_issues = false): void |
||
110 | { |
||
111 | //Get all installed PHP extensions |
||
112 | $extensions = get_loaded_extensions(); |
||
113 | $io->isVerbose() && $io->comment('Your PHP installation has '. count($extensions) .' extensions installed: '. implode(', ', $extensions)); |
||
114 | |||
115 | $db_drivers_count = 0; |
||
116 | if(!in_array('pdo_mysql', $extensions)) { |
||
117 | $io->error('pdo_mysql is not installed. You will not be able to use MySQL databases.'); |
||
118 | } else { |
||
119 | !$only_issues && $io->success('PHP extension pdo_mysql is installed.'); |
||
120 | $db_drivers_count++; |
||
121 | } |
||
122 | |||
123 | if(!in_array('pdo_sqlite', $extensions)) { |
||
124 | $io->error('pdo_sqlite is not installed. You will not be able to use SQLite. databases'); |
||
125 | } else { |
||
126 | !$only_issues && $io->success('PHP extension pdo_sqlite is installed.'); |
||
127 | $db_drivers_count++; |
||
128 | } |
||
129 | |||
130 | $io->isVerbose() && $io->comment('You have '. $db_drivers_count .' database drivers installed.'); |
||
131 | if ($db_drivers_count === 0) { |
||
132 | $io->error('You have no database drivers installed. You have to install at least one database driver!'); |
||
133 | } |
||
134 | |||
135 | if(!in_array('curl', $extensions)) { |
||
136 | $io->warning('curl extension is not installed. Install curl extension for better performance'); |
||
137 | } else { |
||
138 | !$only_issues && $io->success('PHP extension curl is installed.'); |
||
139 | } |
||
140 | |||
141 | $gd_installed = in_array('gd', $extensions); |
||
142 | if(!$gd_installed) { |
||
143 | $io->error('GD is not installed. GD is required for image processing.'); |
||
144 | } else { |
||
145 | !$only_issues && $io->success('PHP extension GD is installed.'); |
||
146 | } |
||
147 | |||
148 | //Check if GD has jpeg support |
||
149 | $io->isVerbose() && $io->comment('Checking if GD has jpeg support...'); |
||
150 | if ($gd_installed) { |
||
151 | $gd_info = gd_info(); |
||
152 | if($gd_info['JPEG Support'] === false) { |
||
153 | $io->warning('Your GD does not have jpeg support. You will not be able to generate thumbnails of jpeg images.'); |
||
154 | } else { |
||
155 | !$only_issues && $io->success('GD has jpeg support.'); |
||
156 | } |
||
157 | |||
158 | if($gd_info['PNG Support'] === false) { |
||
159 | $io->warning('Your GD does not have png support. You will not be able to generate thumbnails of png images.'); |
||
160 | } else { |
||
161 | !$only_issues && $io->success('GD has png support.'); |
||
162 | } |
||
163 | |||
164 | if($gd_info['WebP Support'] === false) { |
||
165 | $io->warning('Your GD does not have WebP support. You will not be able to generate thumbnails of WebP images.'); |
||
166 | } else { |
||
167 | !$only_issues && $io->success('GD has WebP support.'); |
||
168 | } |
||
176 | } |