| Conditions | 14 |
| Paths | 88 |
| Total Lines | 35 |
| Code Lines | 26 |
| 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 |
||
| 88 | private static function createConfidentialObject(Component\VCalendar $vObject) { |
||
| 89 | /** @var Component $vElement */ |
||
| 90 | $vElement = null; |
||
| 91 | if(isset($vObject->VEVENT)) { |
||
| 92 | $vElement = $vObject->VEVENT; |
||
| 93 | } |
||
| 94 | if(isset($vObject->VJOURNAL)) { |
||
| 95 | $vElement = $vObject->VJOURNAL; |
||
| 96 | } |
||
| 97 | if(isset($vObject->VTODO)) { |
||
| 98 | $vElement = $vObject->VTODO; |
||
| 99 | } |
||
| 100 | if(!is_null($vElement)) { |
||
| 101 | foreach ($vElement->children() as &$property) { |
||
| 102 | /** @var Property $property */ |
||
| 103 | switch($property->name) { |
||
| 104 | case 'CREATED': |
||
| 105 | case 'DTSTART': |
||
| 106 | case 'RRULE': |
||
| 107 | case 'DURATION': |
||
| 108 | case 'DTEND': |
||
| 109 | case 'CLASS': |
||
| 110 | case 'UID': |
||
| 111 | break; |
||
| 112 | case 'SUMMARY': |
||
| 113 | $property->setValue('Busy'); |
||
| 114 | break; |
||
| 115 | default: |
||
| 116 | $vElement->__unset($property->name); |
||
| 117 | unset($property); |
||
| 118 | break; |
||
| 119 | } |
||
| 120 | } |
||
| 121 | } |
||
| 122 | } |
||
| 123 | |||
| 146 |
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.