Conditions | 1 |
Paths | 1 |
Total Lines | 110 |
Code Lines | 82 |
Lines | 0 |
Ratio | 0 % |
Changes | 1 | ||
Bugs | 0 | Features | 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 |
||
112 | public function statementOrderProvider() { |
||
113 | $statement1 = new Statement( new PropertyNoValueSnak( 1 ), null, null, 's1' ); |
||
114 | $statement2 = new Statement( new PropertyNoValueSnak( 2 ), null, null, 's2' ); |
||
115 | $statement3 = new Statement( new PropertyNoValueSnak( 3 ), null, null, 's3' ); |
||
116 | |||
117 | return array( |
||
118 | 'Simple associative add' => array( |
||
119 | new StatementList(), |
||
120 | new Diff( array( |
||
121 | 's1' => new DiffOpAdd( $statement1 ), |
||
122 | ), true ), |
||
123 | array( 's1' ) |
||
124 | ), |
||
125 | 'Simple non-associative add' => array( |
||
126 | new StatementList(), |
||
127 | new Diff( array( |
||
128 | 's1' => new DiffOpAdd( $statement1 ), |
||
129 | ), false ), |
||
130 | array( 's1' ) |
||
131 | ), |
||
132 | 'Simple associative remove' => array( |
||
133 | new StatementList( $statement1 ), |
||
134 | new Diff( array( |
||
135 | 's1' => new DiffOpRemove( $statement1 ), |
||
136 | ), true ), |
||
137 | array() |
||
138 | ), |
||
139 | 'Simple non-associative remove' => array( |
||
140 | new StatementList( $statement1 ), |
||
141 | new Diff( array( |
||
142 | 's1' => new DiffOpRemove( $statement1 ), |
||
143 | ), false ), |
||
144 | array() |
||
145 | ), |
||
146 | |||
147 | // Change operations |
||
148 | 'Remove and add' => array( |
||
149 | new StatementList( $statement1 ), |
||
150 | new Diff( array( |
||
151 | 's1' => new DiffOpRemove( $statement1 ), |
||
152 | 's2' => new DiffOpAdd( $statement2 ), |
||
153 | ) ), |
||
154 | array( 's2' ) |
||
155 | ), |
||
156 | 'Add and remove' => array( |
||
157 | new StatementList( $statement1 ), |
||
158 | new Diff( array( |
||
159 | 's2' => new DiffOpAdd( $statement2 ), |
||
160 | 's1' => new DiffOpRemove( $statement1 ), |
||
161 | ) ), |
||
162 | array( 's2' ) |
||
163 | ), |
||
164 | 'Simple associative replace' => array( |
||
165 | new StatementList( $statement1 ), |
||
166 | new Diff( array( |
||
167 | 's1' => new DiffOpChange( $statement1, $statement2 ), |
||
168 | ), true ), |
||
169 | array( 's2' ) |
||
170 | ), |
||
171 | 'Simple non-associative replace' => array( |
||
172 | new StatementList( $statement1 ), |
||
173 | new Diff( array( |
||
174 | 's1' => new DiffOpChange( $statement1, $statement2 ), |
||
175 | ), false ), |
||
176 | array( 's2' ) |
||
177 | ), |
||
178 | 'Replacing first element retains order' => array( |
||
179 | new StatementList( $statement1, $statement2 ), |
||
180 | new Diff( array( |
||
181 | 's1' => new DiffOpChange( $statement1, $statement3 ), |
||
182 | ) ), |
||
183 | array( 's3', 's2' ) |
||
184 | ), |
||
185 | 'Replacing last element retains order' => array( |
||
186 | new StatementList( $statement1, $statement2 ), |
||
187 | new Diff( array( |
||
188 | 's2' => new DiffOpChange( $statement2, $statement3 ), |
||
189 | ) ), |
||
190 | array( 's1', 's3' ) |
||
191 | ), |
||
192 | |||
193 | // No-ops |
||
194 | 'Empty diff' => array( |
||
195 | new StatementList( $statement1 ), |
||
196 | new Diff(), |
||
197 | array( 's1' ) |
||
198 | ), |
||
199 | 'Adding existing element is no-op' => array( |
||
200 | new StatementList( $statement1 ), |
||
201 | new Diff( array( |
||
202 | 's1' => new DiffOpAdd( $statement1 ), |
||
203 | ) ), |
||
204 | array( 's1' ) |
||
205 | ), |
||
206 | 'Removing non-existing element is no-op' => array( |
||
207 | new StatementList( $statement1 ), |
||
208 | new Diff( array( |
||
209 | 's2' => new DiffOpRemove( $statement2 ), |
||
210 | ) ), |
||
211 | array( 's1' ) |
||
212 | ), |
||
213 | 'Replacing non-existing element is no-op' => array( |
||
214 | new StatementList( $statement1 ), |
||
215 | new Diff( array( |
||
216 | 's2' => new DiffOpChange( $statement2, $statement3 ), |
||
217 | ) ), |
||
218 | array( 's1' ) |
||
219 | ), |
||
220 | ); |
||
221 | } |
||
222 | |||
285 |