| Conditions | 11 |
| Paths | 16 |
| Total Lines | 36 |
| Code Lines | 18 |
| 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 |
||
| 27 | private function getFullName($attributes) |
||
| 28 | { |
||
| 29 | if (isset($attributes['displayName'])) { |
||
| 30 | return $attributes['displayName'][0]; |
||
| 31 | } |
||
| 32 | |||
| 33 | if (isset($attributes['cn'])) { |
||
| 34 | if (count(explode(' ', $attributes['cn'][0])) > 1) { |
||
| 35 | return $attributes['cn'][0]; |
||
| 36 | } |
||
| 37 | } |
||
| 38 | |||
| 39 | if (isset($attributes['sn']) && isset($attributes['givenName'])) { |
||
| 40 | return $attributes['givenName'][0].' '.$attributes['sn'][0]; |
||
| 41 | } |
||
| 42 | |||
| 43 | if (isset($attributes['cn'])) { |
||
| 44 | return $attributes['cn'][0]; |
||
| 45 | } |
||
| 46 | |||
| 47 | if (isset($attributes['sn'])) { |
||
| 48 | return $attributes['sn'][0]; |
||
| 49 | } |
||
| 50 | |||
| 51 | if (isset($attributes['givenName'])) { |
||
| 52 | return $attributes['givenName'][0]; |
||
| 53 | } |
||
| 54 | |||
| 55 | if (isset($attributes['eduPersonPrincipalName'])) { |
||
| 56 | $localname = $this->getLocalUser($attributes['eduPersonPrincipalName'][0]); |
||
| 57 | if (isset($localname)) { |
||
| 58 | return $localname; |
||
| 59 | } |
||
| 60 | } |
||
| 61 | |||
| 62 | return null; |
||
| 63 | } |
||
| 105 |