Conditions | 5 |
Paths | 5 |
Total Lines | 54 |
Lines | 14 |
Ratio | 25.93 % |
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 |
||
42 | public function shared(array $params) { |
||
43 | if($params['shareType'] === Share::SHARE_TYPE_LINK) { |
||
44 | $this->log( |
||
45 | 'The %s "%s" with ID "%s" has been shared via link with permissions "%s" (Share ID: %s)', |
||
46 | $params, |
||
47 | [ |
||
48 | 'itemType', |
||
49 | 'itemTarget', |
||
50 | 'itemSource', |
||
51 | 'permissions', |
||
52 | 'id', |
||
53 | ] |
||
54 | ); |
||
55 | View Code Duplication | } elseif($params['shareType'] === Share::SHARE_TYPE_USER) { |
|
56 | $this->log( |
||
57 | 'The %s "%s" with ID "%s" has been shared to the user "%s" with permissions "%s" (Share ID: %s)', |
||
58 | $params, |
||
59 | [ |
||
60 | 'itemType', |
||
61 | 'itemTarget', |
||
62 | 'itemSource', |
||
63 | 'shareWith', |
||
64 | 'permissions', |
||
65 | 'id', |
||
66 | ] |
||
67 | ); |
||
68 | } elseif($params['shareType'] === Share::SHARE_TYPE_GROUP) { |
||
69 | $this->log( |
||
70 | 'The %s "%s" with ID "%s" has been shared to the group "%s" with permissions "%s" (Share ID: %s)', |
||
71 | $params, |
||
72 | [ |
||
73 | 'itemType', |
||
74 | 'itemTarget', |
||
75 | 'itemSource', |
||
76 | 'shareWith', |
||
77 | 'permissions', |
||
78 | 'id', |
||
79 | ] |
||
80 | ); |
||
81 | } elseif($params['shareType'] === Share::SHARE_TYPE_ROOM) { |
||
82 | $this->log( |
||
83 | 'The %s "%s" with ID "%s" has been shared to the room "%s" with permissions "%s" (Share ID: %s)', |
||
84 | $params, |
||
85 | [ |
||
86 | 'itemType', |
||
87 | 'itemTarget', |
||
88 | 'itemSource', |
||
89 | 'shareWith', |
||
90 | 'permissions', |
||
91 | 'id', |
||
92 | ] |
||
93 | ); |
||
94 | } |
||
95 | } |
||
96 | |||
222 |