Conditions | 1 |
Paths | 1 |
Total Lines | 91 |
Code Lines | 78 |
Lines | 0 |
Ratio | 0 % |
Changes | 2 | ||
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 |
||
181 | public function testSearchItems() |
||
182 | { |
||
183 | $item = $this->object->find( '[email protected]', ['text'] ); |
||
184 | $listItem = $item->getListItems( 'text', 'default' )->first( new \RuntimeException( 'No list item found' ) ); |
||
185 | |||
186 | $search = $this->object->filter(); |
||
187 | |||
188 | $expr = []; |
||
189 | $expr[] = $search->compare( '!=', 'customer.id', null ); |
||
190 | $expr[] = $search->compare( '==', 'customer.label', 'unitCustomer001' ); |
||
191 | $expr[] = $search->compare( '==', 'customer.code', '[email protected]' ); |
||
192 | $expr[] = $search->compare( '>=', 'customer.password', '' ); |
||
193 | $expr[] = $search->compare( '==', 'customer.status', 1 ); |
||
194 | $expr[] = $search->compare( '>', 'customer.mtime', '1970-01-01 00:00:00' ); |
||
195 | $expr[] = $search->compare( '>', 'customer.ctime', '1970-01-01 00:00:00' ); |
||
196 | $expr[] = $search->compare( '!=', 'customer.editor', '' ); |
||
197 | |||
198 | $expr[] = $search->compare( '==', 'customer.salutation', 'mr' ); |
||
199 | $expr[] = $search->compare( '==', 'customer.address.type', 'delivery' ); |
||
200 | $expr[] = $search->compare( '==', 'customer.company', 'Example company' ); |
||
201 | $expr[] = $search->compare( '==', 'customer.vatid', 'DE999999999' ); |
||
202 | $expr[] = $search->compare( '==', 'customer.title', 'Dr' ); |
||
203 | $expr[] = $search->compare( '==', 'customer.firstname', 'Our' ); |
||
204 | $expr[] = $search->compare( '==', 'customer.lastname', 'Unittest' ); |
||
205 | $expr[] = $search->compare( '==', 'customer.address1', 'Pickhuben' ); |
||
206 | $expr[] = $search->compare( '==', 'customer.address2', '2-4' ); |
||
207 | $expr[] = $search->compare( '==', 'customer.address3', '' ); |
||
208 | $expr[] = $search->compare( '==', 'customer.postal', '20457' ); |
||
209 | $expr[] = $search->compare( '==', 'customer.city', 'Hamburg' ); |
||
210 | $expr[] = $search->compare( '==', 'customer.state', 'Hamburg' ); |
||
211 | $expr[] = $search->compare( '==', 'customer.languageid', 'de' ); |
||
212 | $expr[] = $search->compare( '==', 'customer.countryid', 'DE' ); |
||
213 | $expr[] = $search->compare( '==', 'customer.telephone', '055544332211' ); |
||
214 | $expr[] = $search->compare( '==', 'customer.telefax', '055544332212' ); |
||
215 | $expr[] = $search->compare( '==', 'customer.mobile', '055544332213' ); |
||
216 | $expr[] = $search->compare( '==', 'customer.email', '[email protected]' ); |
||
217 | $expr[] = $search->compare( '==', 'customer.website', 'www.example.com' ); |
||
218 | $expr[] = $search->compare( '==', 'customer.longitude', '10.0' ); |
||
219 | $expr[] = $search->compare( '==', 'customer.latitude', '50.0' ); |
||
220 | $expr[] = $search->compare( '==', 'customer.birthday', '1999-01-01' ); |
||
221 | |||
222 | $param = ['text', 'default', $listItem->getRefId()]; |
||
223 | $expr[] = $search->compare( '!=', $search->make( 'customer:has', $param ), null ); |
||
224 | |||
225 | $param = ['text', 'default']; |
||
226 | $expr[] = $search->compare( '!=', $search->make( 'customer:has', $param ), null ); |
||
227 | |||
228 | $param = ['text']; |
||
229 | $expr[] = $search->compare( '!=', $search->make( 'customer:has', $param ), null ); |
||
230 | |||
231 | $param = ['newsletter', null, '1']; |
||
232 | $expr[] = $search->compare( '!=', $search->make( 'customer:prop', $param ), null ); |
||
233 | |||
234 | $param = ['newsletter', null]; |
||
235 | $expr[] = $search->compare( '!=', $search->make( 'customer:prop', $param ), null ); |
||
236 | |||
237 | $param = ['newsletter']; |
||
238 | $expr[] = $search->compare( '!=', $search->make( 'customer:prop', $param ), null ); |
||
239 | |||
240 | $expr[] = $search->compare( '!=', 'customer.address.id', null ); |
||
241 | $expr[] = $search->compare( '!=', 'customer.address.parentid', null ); |
||
242 | $expr[] = $search->compare( '==', 'customer.address.salutation', 'mr' ); |
||
243 | $expr[] = $search->compare( '==', 'customer.address.company', 'Example company' ); |
||
244 | $expr[] = $search->compare( '==', 'customer.address.vatid', 'DE999999999' ); |
||
245 | $expr[] = $search->compare( '==', 'customer.address.title', 'Dr' ); |
||
246 | $expr[] = $search->compare( '==', 'customer.address.firstname', 'Our' ); |
||
247 | $expr[] = $search->compare( '==', 'customer.address.lastname', 'Unittest' ); |
||
248 | $expr[] = $search->compare( '==', 'customer.address.address1', 'Pickhuben' ); |
||
249 | $expr[] = $search->compare( '==', 'customer.address.address2', '2-4' ); |
||
250 | $expr[] = $search->compare( '==', 'customer.address.address3', '' ); |
||
251 | $expr[] = $search->compare( '==', 'customer.address.postal', '20457' ); |
||
252 | $expr[] = $search->compare( '==', 'customer.address.city', 'Hamburg' ); |
||
253 | $expr[] = $search->compare( '==', 'customer.address.state', 'Hamburg' ); |
||
254 | $expr[] = $search->compare( '==', 'customer.address.languageid', 'de' ); |
||
255 | $expr[] = $search->compare( '==', 'customer.address.countryid', 'DE' ); |
||
256 | $expr[] = $search->compare( '==', 'customer.address.telephone', '055544332211' ); |
||
257 | $expr[] = $search->compare( '==', 'customer.address.telefax', '055544332212' ); |
||
258 | $expr[] = $search->compare( '==', 'customer.address.mobile', '055544332213' ); |
||
259 | $expr[] = $search->compare( '==', 'customer.address.email', '[email protected]' ); |
||
260 | $expr[] = $search->compare( '==', 'customer.address.website', 'www.example.com' ); |
||
261 | $expr[] = $search->compare( '==', 'customer.address.longitude', '10.0' ); |
||
262 | $expr[] = $search->compare( '==', 'customer.address.latitude', '50.0' ); |
||
263 | $expr[] = $search->compare( '==', 'customer.address.position', 0 ); |
||
264 | $expr[] = $search->compare( '==', 'customer.address.birthday', '2000-01-01' ); |
||
265 | $expr[] = $search->compare( '>=', 'customer.address.mtime', '1970-01-01 00:00:00' ); |
||
266 | $expr[] = $search->compare( '>=', 'customer.address.ctime', '1970-01-01 00:00:00' ); |
||
267 | $expr[] = $search->compare( '!=', 'customer.address.editor', '' ); |
||
268 | |||
269 | $search->setConditions( $search->and( $expr ) ); |
||
270 | $result = $this->object->search( $search ); |
||
271 | $this->assertEquals( 1, count( $result ) ); |
||
272 | } |
||
327 |