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