| Conditions | 6 |
| Paths | 6 |
| Total Lines | 58 |
| Code Lines | 44 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 1 | ||
| Bugs | 0 | Features | 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 |
||
| 115 | public function unshare(array $params) { |
||
| 116 | if($params['shareType'] === Share::SHARE_TYPE_LINK) { |
||
| 117 | $this->log( |
||
| 118 | 'The %s "%s" with ID "%s" has been unshared (Share ID: %s)', |
||
| 119 | $params, |
||
| 120 | [ |
||
| 121 | 'itemType', |
||
| 122 | 'fileTarget', |
||
| 123 | 'itemSource', |
||
| 124 | 'id', |
||
| 125 | ] |
||
| 126 | ); |
||
| 127 | } elseif($params['shareType'] === Share::SHARE_TYPE_USER) { |
||
| 128 | $this->log( |
||
| 129 | 'The %s "%s" with ID "%s" has been unshared from the user "%s" (Share ID: %s)', |
||
| 130 | $params, |
||
| 131 | [ |
||
| 132 | 'itemType', |
||
| 133 | 'fileTarget', |
||
| 134 | 'itemSource', |
||
| 135 | 'shareWith', |
||
| 136 | 'id', |
||
| 137 | ] |
||
| 138 | ); |
||
| 139 | } elseif($params['shareType'] === Share::SHARE_TYPE_GROUP) { |
||
| 140 | $this->log( |
||
| 141 | 'The %s "%s" with ID "%s" has been unshared from the group "%s" (Share ID: %s)', |
||
| 142 | $params, |
||
| 143 | [ |
||
| 144 | 'itemType', |
||
| 145 | 'fileTarget', |
||
| 146 | 'itemSource', |
||
| 147 | 'shareWith', |
||
| 148 | 'id', |
||
| 149 | ] |
||
| 150 | ); |
||
| 151 | } elseif($params['shareType'] === Share::SHARE_TYPE_ROOM) { |
||
| 152 | $this->log( |
||
| 153 | 'The %s "%s" with ID "%s" has been unshared from the room "%s" (Share ID: %s)', |
||
| 154 | $params, |
||
| 155 | [ |
||
| 156 | 'itemType', |
||
| 157 | 'fileTarget', |
||
| 158 | 'itemSource', |
||
| 159 | 'shareWith', |
||
| 160 | 'id', |
||
| 161 | ] |
||
| 162 | ); |
||
| 163 | } elseif($params['shareType'] === Share::SHARE_TYPE_EMAIL) { |
||
| 164 | $this->log( |
||
| 165 | 'The %s "%s" with ID "%s" has been unshared from the email recipient "%s" (Share ID: %s)', |
||
| 166 | $params, |
||
| 167 | [ |
||
| 168 | 'itemType', |
||
| 169 | 'fileTarget', |
||
| 170 | 'itemSource', |
||
| 171 | 'shareWith', |
||
| 172 | 'id', |
||
| 173 | ] |
||
| 247 |