Conditions | 12 |
Paths | 36 |
Total Lines | 26 |
Code Lines | 21 |
Lines | 0 |
Ratio | 0 % |
Tests | 15 |
CRAP Score | 16.6393 |
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 | 36 | public function unserialize($serialized) { |
|
43 | 36 | $data = unserialize($serialized); |
|
44 | 36 | if (isset($data->action)) { |
|
45 | 36 | $this->action = $data->action; |
|
1 ignored issue
–
show
|
|||
46 | } |
||
47 | 36 | if (isset($data->object_id) && isset($data->object_type)) { |
|
48 | 36 | switch ($data->object_type) { |
|
49 | case 'object' : |
||
50 | case 'user' : |
||
51 | case 'group' : |
||
52 | case 'site' : |
||
53 | 18 | $this->object = get_entity($data->object_id); |
|
1 ignored issue
–
show
|
|||
54 | 18 | break; |
|
55 | case 'annotation' : |
||
56 | 6 | $this->object = elgg_get_annotation_from_id($data->object_id); |
|
57 | 6 | break; |
|
58 | case 'metadata' : |
||
59 | 6 | $this->object = elgg_get_metadata_from_id($data->object_id); |
|
60 | 6 | break; |
|
61 | case 'relationship' : |
||
62 | 6 | $this->object = get_relationship($data->object_id); |
|
63 | } |
||
64 | } |
||
65 | |||
66 | 36 | if (isset($data->actor_guid)) { |
|
67 | 36 | $this->actor = get_entity($data->actor_guid); |
|
1 ignored issue
–
show
|
|||
68 | } |
||
72 |