| Conditions | 10 |
| Paths | 8 |
| Total Lines | 29 |
| 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 |
||
| 11 | static function vendor2web(Event $event) { |
||
|
|
|||
| 12 | $options = self::getOptions($event); |
||
| 13 | if (isset($options['vendor2web']) && is_array($options['vendor2web'])) { |
||
| 14 | print "Installing vendor assets to web\n"; |
||
| 15 | $installType = $options['symfony-assets-install']; // hard|symlink|relative |
||
| 16 | $webDir = $options['web-dir-full']; |
||
| 17 | $vendorDir = $options['vendor-dir-full']; |
||
| 18 | if ($installType != 'hard' && $installType != 'symlink' && $installType != 'relative') { |
||
| 19 | print "ERROR: Unknown install type $installType \n"; |
||
| 20 | return; |
||
| 21 | } |
||
| 22 | if (!is_dir($webDir)) { |
||
| 23 | print "ERROR: No web dir $webDir \n"; |
||
| 24 | return; |
||
| 25 | } |
||
| 26 | if (!is_dir(($vendorDir))) { |
||
| 27 | print "ERROR: No vendor dir $vendorDir \n"; |
||
| 28 | return; |
||
| 29 | } |
||
| 30 | if (!is_dir($webDir.DIRECTORY_SEPARATOR.'vendor')) { |
||
| 31 | mkdir($webDir.DIRECTORY_SEPARATOR.'vendor'); |
||
| 32 | } |
||
| 33 | self::_deleteOldWebVendors($webDir); |
||
| 34 | print "Installing new vendors to web:\n"; |
||
| 35 | foreach ($options['vendor2web'] as $vendor=>$destination) { |
||
| 36 | self::_installVendorToWeb($vendor, $destination, $webDir, $vendorDir, $installType); |
||
| 37 | } |
||
| 38 | } |
||
| 39 | } |
||
| 40 | |||
| 107 |
Adding explicit visibility (
private,protected, orpublic) is generally recommend to communicate to other developers how, and from where this method is intended to be used.