| Conditions | 2 | 
| Paths | 2 | 
| Total Lines | 99 | 
| Code Lines | 83 | 
| 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 | ||
| 170 | public function testSearchItems() | ||
| 171 | 	{ | ||
| 172 | $total = 0; | ||
| 173 | $search = $this->object->createSearch(); | ||
| 174 | |||
| 175 | $expr = array(); | ||
| 176 | $expr[] = $search->compare( '!=', 'customer.id', null ); | ||
| 177 | $expr[] = $search->compare( '==', 'customer.label', 'Franz-Xaver Gabler' ); | ||
| 178 | $expr[] = $search->compare( '==', 'customer.code', '[email protected]' ); | ||
| 179 | $expr[] = $search->compare( '==', 'customer.salutation', 'mr' ); | ||
| 180 | $expr[] = $search->compare( '==', 'customer.company', 'Example company LLC' ); | ||
| 181 | $expr[] = $search->compare( '==', 'customer.title', '' ); | ||
| 182 | $expr[] = $search->compare( '==', 'customer.firstname', 'Franz-Xaver' ); | ||
| 183 | $expr[] = $search->compare( '==', 'customer.lastname', 'Gabler' ); | ||
| 184 | $expr[] = $search->compare( '==', 'customer.address1', 'Phantasiestraße 2' ); | ||
| 185 | $expr[] = $search->compare( '==', 'customer.postal', '23643' ); | ||
| 186 | $expr[] = $search->compare( '==', 'customer.city', 'Berlin' ); | ||
| 187 | $expr[] = $search->compare( '==', 'customer.state', 'Berlin' ); | ||
| 188 | $expr[] = $search->compare( '==', 'customer.telephone', '01234509876' ); | ||
| 189 | $expr[] = $search->compare( '==', 'customer.email', '[email protected]' ); | ||
| 190 | $expr[] = $search->compare( '==', 'customer.telefax', '055544333212' ); | ||
| 191 | $expr[] = $search->compare( '==', 'customer.website', 'www.example.com' ); | ||
| 192 | $expr[] = $search->compare( '==', 'customer.status', 1 ); | ||
| 193 | $expr[] = $search->compare( '!=', 'customer.password', '' ); | ||
| 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 | |||
| 197 | $expr[] = $search->compare( '!=', 'customer.address.id', null ); | ||
| 198 | $expr[] = $search->compare( '!=', 'customer.address.siteid', null ); | ||
| 199 | $expr[] = $search->compare( '!=', 'customer.address.parentid', null ); | ||
| 200 | $expr[] = $search->compare( '==', 'customer.address.salutation', 'company' ); | ||
| 201 | $expr[] = $search->compare( '==', 'customer.address.company', 'unitcompany' ); | ||
| 202 | $expr[] = $search->compare( '==', 'customer.address.title', 'unittitle' ); | ||
| 203 | $expr[] = $search->compare( '==', 'customer.address.firstname', 'unitfirstname' ); | ||
| 204 | $expr[] = $search->compare( '==', 'customer.address.lastname', 'unitlastname' ); | ||
| 205 | $expr[] = $search->compare( '==', 'customer.address.address1', 'unitaddress1' ); | ||
| 206 | $expr[] = $search->compare( '==', 'customer.address.address2', 'unitaddress2' ); | ||
| 207 | $expr[] = $search->compare( '==', 'customer.address.address3', 'unitaddress3' ); | ||
| 208 | $expr[] = $search->compare( '==', 'customer.address.postal', 'unitpostal' ); | ||
| 209 | $expr[] = $search->compare( '==', 'customer.address.city', 'unitcity' ); | ||
| 210 | $expr[] = $search->compare( '==', 'customer.address.state', 'unitstate' ); | ||
| 211 | $expr[] = $search->compare( '==', 'customer.address.countryid', 'DE' ); | ||
| 212 | $expr[] = $search->compare( '==', 'customer.address.languageid', 'de' ); | ||
| 213 | $expr[] = $search->compare( '==', 'customer.address.telephone', '1234567890' ); | ||
| 214 | $expr[] = $search->compare( '==', 'customer.address.email', '[email protected]' ); | ||
| 215 | $expr[] = $search->compare( '==', 'customer.address.telefax', '1234567891' ); | ||
| 216 | $expr[] = $search->compare( '==', 'customer.address.website', 'unit.web.site' ); | ||
| 217 | $expr[] = $search->compare( '==', 'customer.address.flag', 0 ); | ||
| 218 | $expr[] = $search->compare( '==', 'customer.address.position', 2 ); | ||
| 219 | $expr[] = $search->compare( '==', 'customer.address.editor', $this->editor ); | ||
| 220 | $expr[] = $search->compare( '>', 'customer.address.mtime', '1970-01-01 00:00:00' ); | ||
| 221 | $expr[] = $search->compare( '>', 'customer.address.ctime', '1970-01-01 00:00:00' ); | ||
| 222 | |||
| 223 | $expr[] = $search->compare( '!=', 'customer.lists.id', null ); | ||
| 224 | $expr[] = $search->compare( '!=', 'customer.lists.siteid', null ); | ||
| 225 | $expr[] = $search->compare( '!=', 'customer.lists.parentid', null ); | ||
| 226 | $expr[] = $search->compare( '==', 'customer.lists.domain', 'text' ); | ||
| 227 | $expr[] = $search->compare( '>', 'customer.lists.typeid', 0 ); | ||
| 228 | $expr[] = $search->compare( '>', 'customer.lists.refid', 0 ); | ||
| 229 | $expr[] = $search->compare( '==', 'customer.lists.datestart', '2010-01-01 00:00:00' ); | ||
| 230 | $expr[] = $search->compare( '==', 'customer.lists.dateend', '2022-01-01 00:00:00' ); | ||
| 231 | $expr[] = $search->compare( '>', 'customer.lists.position', 0 ); | ||
| 232 | $expr[] = $search->compare( '>=', 'customer.lists.mtime', '1970-01-01 00:00:00' ); | ||
| 233 | $expr[] = $search->compare( '>=', 'customer.lists.ctime', '1970-01-01 00:00:00' ); | ||
| 234 | $expr[] = $search->compare( '==', 'customer.lists.editor', $this->editor ); | ||
| 235 | |||
| 236 | $expr[] = $search->compare( '!=', 'customer.lists.type.id', null ); | ||
| 237 | $expr[] = $search->compare( '!=', 'customer.lists.type.siteid', null ); | ||
| 238 | $expr[] = $search->compare( '==', 'customer.lists.type.code', 'default' ); | ||
| 239 | $expr[] = $search->compare( '==', 'customer.lists.type.domain', 'text' ); | ||
| 240 | $expr[] = $search->compare( '==', 'customer.lists.type.label', 'Standard' ); | ||
| 241 | $expr[] = $search->compare( '==', 'customer.lists.type.status', 1 ); | ||
| 242 | $expr[] = $search->compare( '>=', 'customer.lists.type.mtime', '1970-01-01 00:00:00' ); | ||
| 243 | $expr[] = $search->compare( '>=', 'customer.lists.type.ctime', '1970-01-01 00:00:00' ); | ||
| 244 | $expr[] = $search->compare( '==', 'customer.lists.type.editor', $this->editor ); | ||
| 245 | |||
| 246 | $search->setConditions( $search->combine( '&&', $expr ) ); | ||
| 247 | $result = $this->object->searchItems( $search, array(), $total ); | ||
| 248 | |||
| 249 | $this->assertEquals( 1, count( $result ) ); | ||
| 250 | $this->assertEquals( 1, $total ); | ||
| 251 | $this->assertEquals( array( 1, 2, 3 ), reset( $result )->getGroups() ); | ||
| 252 | |||
| 253 | |||
| 254 | // search without base criteria | ||
| 255 | $search = $this->object->createSearch(); | ||
| 256 | $results = $this->object->searchItems( $search ); | ||
| 257 | $this->assertEquals( 3, count( $results ) ); | ||
| 258 | |||
| 259 | |||
| 260 | // search with base criteria | ||
| 261 | $search = $this->object->createSearch(true); | ||
| 262 | $results = $this->object->searchItems( $search ); | ||
| 263 | $this->assertEquals( 2, count( $results ) ); | ||
| 264 | |||
| 265 | 		foreach( $results as $itemId => $item ) { | ||
| 266 | $this->assertEquals( $itemId, $item->getId() ); | ||
| 267 | } | ||
| 268 | } | ||
| 269 | |||
| 284 |