| Conditions | 14 | 
| Paths | 41 | 
| Total Lines | 33 | 
| Code Lines | 20 | 
| 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 | ||
| 33 | public function linkUrlFilter($uri, $vocab, $lang, $type = 'page', $clang = null, $term = null) | ||
| 34 |     { | ||
| 35 | // $vocab can either be null, a vocabulary id (string) or a Vocabulary object | ||
| 36 |         if ($vocab === null) { | ||
| 37 | return $uri; | ||
| 38 |         } elseif (is_string($vocab)) { | ||
|  | |||
| 39 | $vocid = $vocab; | ||
| 40 | $vocab = $this->model->getVocabulary($vocid); | ||
| 41 |         } else { | ||
| 42 | $vocid = $vocab->getId(); | ||
| 43 | } | ||
| 44 | |||
| 45 | $params = []; | ||
| 46 |         if (isset($clang) && $clang !== $lang) { | ||
| 47 | $params['clang'] = $clang; | ||
| 48 | } | ||
| 49 | |||
| 50 |         if (isset($term)) { | ||
| 51 | $params['q'] = $term; | ||
| 52 | } | ||
| 53 | |||
| 54 | $localname = $vocab->getLocalName($uri); | ||
| 55 |         if ($localname !== $uri && $localname === urlencode($localname)) { | ||
| 56 | $paramstr = count($params) > 0 ? '?' . http_build_query($params) : ''; | ||
| 57 |             if ($type && $type !== '' && $type !== 'vocab' && !($localname === '' && $type === 'page')) { | ||
| 58 | return "$vocid/$lang/$type/$localname" . $paramstr; | ||
| 59 | } | ||
| 60 | |||
| 61 | return "$vocid/$lang/$localname" . $paramstr; | ||
| 62 | } | ||
| 63 | |||
| 64 | $params['uri'] = $uri; | ||
| 65 | return "$vocid/$lang/$type/?" . http_build_query($params); | ||
| 66 | } | ||
| 68 |