Conditions | 1 |
Paths | 1 |
Total Lines | 53 |
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 |
||
58 | public function testGetAll() { |
||
59 | $return = array( |
||
60 | array( |
||
61 | 'id' => "starred", |
||
62 | 'displayName' => 'Important', |
||
63 | 'show' => 2, |
||
64 | 'icon' => 'icon-task-star'), |
||
65 | array( |
||
66 | 'id' => "today", |
||
67 | 'displayName' => 'Today', |
||
68 | 'show' => 2, |
||
69 | 'icon' => 'icon-calendar'), |
||
70 | array( |
||
71 | 'id' => "week", |
||
72 | 'displayName' => 'Week', |
||
73 | 'show' => 2, |
||
74 | 'icon' => 'icon-calendar'), |
||
75 | array( |
||
76 | 'id' => "all", |
||
77 | 'displayName' => 'All', |
||
78 | 'show' => 2, |
||
79 | 'icon' => 'icon-all'), |
||
80 | array( |
||
81 | 'id' => "current", |
||
82 | 'displayName' => 'Current', |
||
83 | 'show' => 2, |
||
84 | 'icon' => 'icon-current'), |
||
85 | array( |
||
86 | 'id' => "completed", |
||
87 | 'displayName' => 'Completed', |
||
88 | 'show' => 2, |
||
89 | 'icon' => 'icon-checkmark') |
||
90 | ); |
||
91 | |||
92 | $map = [ |
||
93 | ['Important', [],'Important'], |
||
94 | ['Today', [], 'Today'], |
||
95 | ['Week', [], 'Week'], |
||
96 | ['All', [], 'All'], |
||
97 | ['Completed', [], 'Completed'], |
||
98 | ['Current', [], 'Current'] |
||
99 | ]; |
||
100 | |||
101 | $this->l10n->expects($this->any()) |
||
102 | ->method('t') |
||
103 | ->will( |
||
104 | $this->returnValueMap($map) |
||
105 | ); |
||
106 | |||
107 | $result = $this->collectionsService->getAll(); |
||
108 | |||
109 | $this->assertEquals($return, $result); |
||
110 | } |
||
111 | |||
133 |