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 |
||
21 | private function getFullName(array $attributes): ?string |
||
22 | { |
||
23 | if (isset($attributes['displayName'])) { |
||
24 | return $attributes['displayName'][0]; |
||
25 | } |
||
26 | |||
27 | if (isset($attributes['cn'])) { |
||
28 | if (count(explode(' ', $attributes['cn'][0])) > 1) { |
||
29 | return $attributes['cn'][0]; |
||
30 | } |
||
31 | } |
||
32 | |||
33 | if (isset($attributes['sn']) && isset($attributes['givenName'])) { |
||
34 | return $attributes['givenName'][0] . ' ' . $attributes['sn'][0]; |
||
35 | } |
||
36 | |||
37 | if (isset($attributes['cn'])) { |
||
38 | return $attributes['cn'][0]; |
||
39 | } |
||
40 | |||
41 | if (isset($attributes['sn'])) { |
||
42 | return $attributes['sn'][0]; |
||
43 | } |
||
44 | |||
45 | if (isset($attributes['givenName'])) { |
||
46 | return $attributes['givenName'][0]; |
||
47 | } |
||
48 | |||
49 | if (isset($attributes['eduPersonPrincipalName'])) { |
||
50 | $localname = $this->getLocalUser($attributes['eduPersonPrincipalName'][0]); |
||
51 | if (isset($localname)) { |
||
52 | return $localname; |
||
53 | } |
||
54 | } |
||
55 | |||
56 | return null; |
||
57 | } |
||
97 |