Conditions | 1 |
Paths | 1 |
Total Lines | 58 |
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 |
||
54 | public function testGet() { |
||
55 | $return = [ |
||
56 | 'defaultCalendarId' => 'personal', |
||
57 | 'showHidden' => 1, |
||
58 | 'sortOrder' => 'default', |
||
59 | 'sortDirection' => false, |
||
60 | 'userID' => $this->userId, |
||
61 | 'allDay' => false |
||
62 | ]; |
||
63 | |||
64 | $map = [ |
||
65 | [ |
||
66 | $this->userId, |
||
67 | $this->appName, |
||
68 | 'various_defaultCalendarId', |
||
69 | '', |
||
70 | 'personal' |
||
71 | ], |
||
72 | [ |
||
73 | $this->userId, |
||
74 | $this->appName, |
||
75 | 'various_showHidden', |
||
76 | '', |
||
77 | 1 |
||
78 | ], |
||
79 | [ |
||
80 | $this->userId, |
||
81 | $this->appName, |
||
82 | 'various_sortOrder', |
||
83 | '', |
||
84 | 'default' |
||
85 | ], |
||
86 | [ |
||
87 | $this->userId, |
||
88 | $this->appName, |
||
89 | 'various_sortDirection', |
||
90 | '', |
||
91 | false |
||
92 | ], |
||
93 | [ |
||
94 | $this->userId, |
||
95 | $this->appName, |
||
96 | 'various_allDay', |
||
97 | '', |
||
98 | false |
||
99 | ] |
||
100 | ]; |
||
101 | |||
102 | $this->settings->expects($this->any()) |
||
103 | ->method('getUserValue') |
||
104 | ->will( |
||
105 | $this->returnValueMap($map) |
||
106 | ); |
||
107 | |||
108 | $result = $this->settingsService->get(); |
||
109 | |||
110 | $this->assertEquals($return, $result); |
||
111 | } |
||
112 | |||
131 |