| Total Lines | 291 |
| Code Lines | 134 |
| 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 |
||
| 62 | public function provideRequirements() |
||
| 63 | { |
||
| 64 | $phpVersion = PHP_VERSION; |
||
| 65 | |||
| 66 | yield (function () use ($phpVersion) { |
||
| 67 | return [ |
||
| 68 | new RequirementCollection(), |
||
| 69 | IO::VERBOSITY_DEBUG, |
||
| 70 | true, |
||
| 71 | <<<EOF |
||
| 72 | |||
| 73 | Box Requirements Checker |
||
| 74 | ======================== |
||
| 75 | |||
| 76 | > Using PHP $phpVersion |
||
| 77 | > PHP is using the following php.ini file: |
||
| 78 | /path/to/php.ini |
||
| 79 | |||
| 80 | > No requirements found. |
||
| 81 | |||
| 82 | |||
| 83 | [OK] Your system is ready to run the application. |
||
| 84 | |||
| 85 | |||
| 86 | |||
| 87 | EOF |
||
| 88 | ]; |
||
| 89 | })(); |
||
| 90 | |||
| 91 | yield (function () use ($phpVersion) { |
||
| 92 | return [ |
||
| 93 | new RequirementCollection(), |
||
| 94 | IO::VERBOSITY_VERY_VERBOSE, |
||
| 95 | true, |
||
| 96 | <<<EOF |
||
| 97 | |||
| 98 | Box Requirements Checker |
||
| 99 | ======================== |
||
| 100 | |||
| 101 | > Using PHP $phpVersion |
||
| 102 | > PHP is using the following php.ini file: |
||
| 103 | /path/to/php.ini |
||
| 104 | |||
| 105 | > No requirements found. |
||
| 106 | |||
| 107 | |||
| 108 | [OK] Your system is ready to run the application. |
||
| 109 | |||
| 110 | |||
| 111 | |||
| 112 | EOF |
||
| 113 | ]; |
||
| 114 | })(); |
||
| 115 | |||
| 116 | foreach ([IO::VERBOSITY_VERBOSE, IO::VERBOSITY_NORMAL, IO::VERBOSITY_QUIET] as $verbosity) { |
||
| 117 | yield (function () use ($verbosity) { |
||
| 118 | return [ |
||
| 119 | new RequirementCollection(), |
||
| 120 | $verbosity, |
||
| 121 | true, |
||
| 122 | '', |
||
| 123 | ]; |
||
| 124 | })(); |
||
| 125 | } |
||
| 126 | |||
| 127 | yield (function () use ($phpVersion) { |
||
| 128 | $requirements = new RequirementCollection(); |
||
| 129 | |||
| 130 | $requirements->addRequirement( |
||
| 131 | new ConditionIsFulfilled(), |
||
| 132 | 'The application requires the version "7.2.0" or greater. Got "7.2.2"', |
||
| 133 | 'The application requires the version "7.2.0" or greater.' |
||
| 134 | ); |
||
| 135 | $requirements->addRequirement( |
||
| 136 | new class implements IsFulfilled { |
||
| 137 | public function __invoke() |
||
| 138 | { |
||
| 139 | return true; |
||
| 140 | } |
||
| 141 | }, |
||
| 142 | 'The package "acme/foo" requires the extension "random". Enable it or install a polyfill.', |
||
| 143 | 'The package "acme/foo" requires the extension "random".' |
||
| 144 | ); |
||
| 145 | |||
| 146 | return [ |
||
| 147 | $requirements, |
||
| 148 | IO::VERBOSITY_DEBUG, |
||
| 149 | true, |
||
| 150 | <<<EOF |
||
| 151 | |||
| 152 | Box Requirements Checker |
||
| 153 | ======================== |
||
| 154 | |||
| 155 | > Using PHP $phpVersion |
||
| 156 | > PHP is using the following php.ini file: |
||
| 157 | /path/to/php.ini |
||
| 158 | |||
| 159 | > Checking Box requirements: |
||
| 160 | ✔ The application requires the version "7.2.0" or greater. |
||
| 161 | ✔ The package "acme/foo" requires the extension "random". |
||
| 162 | |||
| 163 | |||
| 164 | [OK] Your system is ready to run the application. |
||
| 165 | |||
| 166 | |||
| 167 | |||
| 168 | EOF |
||
| 169 | ]; |
||
| 170 | })(); |
||
| 171 | |||
| 172 | yield (function () use ($phpVersion) { |
||
| 173 | $requirements = new RequirementCollection(); |
||
| 174 | |||
| 175 | $requirements->addRequirement( |
||
| 176 | new ConditionIsFulfilled(), |
||
| 177 | 'The application requires the version "7.2.0" or greater. Got "7.2.2"', |
||
| 178 | 'The application requires the version "7.2.0" or greater.' |
||
| 179 | ); |
||
| 180 | $requirements->addRequirement( |
||
| 181 | new ConditionIsFulfilled(), |
||
| 182 | 'The package "acme/foo" requires the extension "random". Enable it or install a polyfill.', |
||
| 183 | 'The package "acme/foo" requires the extension "random".' |
||
| 184 | ); |
||
| 185 | |||
| 186 | return [ |
||
| 187 | $requirements, |
||
| 188 | IO::VERBOSITY_VERY_VERBOSE, |
||
| 189 | true, |
||
| 190 | <<<EOF |
||
| 191 | |||
| 192 | Box Requirements Checker |
||
| 193 | ======================== |
||
| 194 | |||
| 195 | > Using PHP $phpVersion |
||
| 196 | > PHP is using the following php.ini file: |
||
| 197 | /path/to/php.ini |
||
| 198 | |||
| 199 | > Checking Box requirements: |
||
| 200 | .. |
||
| 201 | |||
| 202 | |||
| 203 | [OK] Your system is ready to run the application. |
||
| 204 | |||
| 205 | |||
| 206 | |||
| 207 | EOF |
||
| 208 | ]; |
||
| 209 | })(); |
||
| 210 | |||
| 211 | foreach ([IO::VERBOSITY_VERBOSE, IO::VERBOSITY_NORMAL, IO::VERBOSITY_QUIET] as $verbosity) { |
||
| 212 | yield (function () use ($verbosity) { |
||
| 213 | $requirements = new RequirementCollection(); |
||
| 214 | |||
| 215 | $requirements->addRequirement( |
||
| 216 | new ConditionIsFulfilled(), |
||
| 217 | 'The application requires the version "7.2.0" or greater. Got "7.2.2"', |
||
| 218 | 'The application requires the version "7.2.0" or greater.' |
||
| 219 | ); |
||
| 220 | $requirements->addRequirement( |
||
| 221 | new ConditionIsFulfilled(), |
||
| 222 | 'The package "acme/foo" requires the extension "random". Enable it or install a polyfill.', |
||
| 223 | 'The package "acme/foo" requires the extension "random".' |
||
| 224 | ); |
||
| 225 | |||
| 226 | return [ |
||
| 227 | $requirements, |
||
| 228 | $verbosity, |
||
| 229 | true, |
||
| 230 | '', |
||
| 231 | ]; |
||
| 232 | })(); |
||
| 233 | } |
||
| 234 | |||
| 235 | yield (function () use ($phpVersion) { |
||
| 236 | $requirements = new RequirementCollection(); |
||
| 237 | |||
| 238 | $requirements->addRequirement( |
||
| 239 | new ConditionIsFulfilled(), |
||
| 240 | 'The application requires the version "7.2.0" or greater. Got "7.2.2"', |
||
| 241 | 'The application requires the version "7.2.0" or greater.' |
||
| 242 | ); |
||
| 243 | $requirements->addRequirement( |
||
| 244 | new ConditionIsNotFulfilled(), |
||
| 245 | 'The package "acme/foo" requires the extension "random". Enable it or install a polyfill.', |
||
| 246 | 'The package "acme/foo" requires the extension "random".' |
||
| 247 | ); |
||
| 248 | |||
| 249 | return [ |
||
| 250 | $requirements, |
||
| 251 | IO::VERBOSITY_DEBUG, |
||
| 252 | false, |
||
| 253 | <<<EOF |
||
| 254 | |||
| 255 | Box Requirements Checker |
||
| 256 | ======================== |
||
| 257 | |||
| 258 | > Using PHP $phpVersion |
||
| 259 | > PHP is using the following php.ini file: |
||
| 260 | /path/to/php.ini |
||
| 261 | |||
| 262 | > Checking Box requirements: |
||
| 263 | ✔ The application requires the version "7.2.0" or greater. |
||
| 264 | ✘ The package "acme/foo" requires the extension "random". Enable it or install |
||
| 265 | a polyfill. |
||
| 266 | |||
| 267 | |||
| 268 | [ERROR] Your system is not ready to run the application. |
||
| 269 | |||
| 270 | |||
| 271 | Fix the following mandatory requirements: |
||
| 272 | ========================================= |
||
| 273 | |||
| 274 | * The package "acme/foo" requires the extension "random". Enable it or install |
||
| 275 | a polyfill. |
||
| 276 | |||
| 277 | |||
| 278 | EOF |
||
| 279 | ]; |
||
| 280 | })(); |
||
| 281 | |||
| 282 | foreach ([IO::VERBOSITY_VERY_VERBOSE, IO::VERBOSITY_VERBOSE, IO::VERBOSITY_NORMAL] as $verbosity) { |
||
| 283 | yield (function () use ($verbosity, $phpVersion) { |
||
| 284 | $requirements = new RequirementCollection(); |
||
| 285 | |||
| 286 | $requirements->addRequirement( |
||
| 287 | new ConditionIsFulfilled(), |
||
| 288 | 'The application requires the version "7.2.0" or greater. Got "7.2.2"', |
||
| 289 | 'The application requires the version "7.2.0" or greater.' |
||
| 290 | ); |
||
| 291 | $requirements->addRequirement( |
||
| 292 | new ConditionIsNotFulfilled(), |
||
| 293 | 'The package "acme/foo" requires the extension "random". Enable it or install a polyfill.', |
||
| 294 | 'The package "acme/foo" requires the extension "random".' |
||
| 295 | ); |
||
| 296 | |||
| 297 | return [ |
||
| 298 | $requirements, |
||
| 299 | $verbosity, |
||
| 300 | false, |
||
| 301 | <<<EOF |
||
| 302 | |||
| 303 | Box Requirements Checker |
||
| 304 | ======================== |
||
| 305 | |||
| 306 | > Using PHP $phpVersion |
||
| 307 | > PHP is using the following php.ini file: |
||
| 308 | /path/to/php.ini |
||
| 309 | |||
| 310 | > Checking Box requirements: |
||
| 311 | .E |
||
| 312 | |||
| 313 | |||
| 314 | [ERROR] Your system is not ready to run the application. |
||
| 315 | |||
| 316 | |||
| 317 | Fix the following mandatory requirements: |
||
| 318 | ========================================= |
||
| 319 | |||
| 320 | * The package "acme/foo" requires the extension "random". Enable it or install |
||
| 321 | a polyfill. |
||
| 322 | |||
| 323 | |||
| 324 | EOF |
||
| 325 | ]; |
||
| 326 | })(); |
||
| 327 | } |
||
| 328 | |||
| 329 | yield (function () use ($phpVersion) { |
||
| 330 | $requirements = new RequirementCollection(); |
||
| 331 | |||
| 332 | $requirements->addRequirement( |
||
| 333 | new ConditionIsFulfilled(), |
||
| 334 | 'The application requires the version "7.2.0" or greater. Got "7.2.2"', |
||
| 335 | 'The application requires the version "7.2.0" or greater.' |
||
| 336 | ); |
||
| 337 | $requirements->addRequirement( |
||
| 338 | new ConditionIsNotFulfilled(), |
||
| 339 | 'The package "acme/foo" requires the extension "random". Enable it or install a polyfill.', |
||
| 340 | 'The package "acme/foo" requires the extension "random".' |
||
| 341 | ); |
||
| 342 | |||
| 343 | return [ |
||
| 344 | $requirements, |
||
| 345 | IO::VERBOSITY_QUIET, |
||
| 346 | false, |
||
| 347 | <<<EOF |
||
| 348 | |||
| 349 | Box Requirements Checker |
||
| 350 | ======================== |
||
| 351 | |||
| 352 | > Using PHP $phpVersion |
||
| 353 | > PHP is using the following php.ini file: |
||
| 375 |
The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g.
excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths