| Conditions | 7 |
| Paths | 16 |
| Total Lines | 140 |
| Code Lines | 108 |
| 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 |
||
| 179 | public function testInternationalToXML() |
||
| 180 | { |
||
| 181 | $data = array( |
||
| 182 | 'sender' => array( |
||
| 183 | 'name' => 'Tijs Verkoyen', |
||
| 184 | 'company' => 'Sumo Coders', |
||
| 185 | 'address' => array( |
||
| 186 | 'streetName' => 'Afrikalaan', |
||
| 187 | 'number' => '289', |
||
| 188 | 'box' => '3', |
||
| 189 | 'postalCode' => '9000', |
||
| 190 | 'locality' => 'Gent', |
||
| 191 | 'countryCode' => 'BE', |
||
| 192 | ), |
||
| 193 | 'emailAddress' => '[email protected]', |
||
| 194 | 'phoneNumber' => '+32 9 395 02 51', |
||
| 195 | ), |
||
| 196 | 'internationalBox' => array( |
||
| 197 | 'international' => array( |
||
| 198 | 'product' => 'bpack World Express Pro', |
||
| 199 | 'receiver' => array( |
||
| 200 | 'name' => 'Tijs Verkoyen', |
||
| 201 | 'company' => 'Sumo Coders', |
||
| 202 | 'address' => array( |
||
| 203 | 'streetName' => 'Kerkstraat', |
||
| 204 | 'number' => '108', |
||
| 205 | 'postalCode' => '9050', |
||
| 206 | 'locality' => 'Gentbrugge', |
||
| 207 | 'countryCode' => 'BE', |
||
| 208 | ), |
||
| 209 | 'emailAddress' => '[email protected]', |
||
| 210 | 'phoneNumber' => '+32 9 395 02 51', |
||
| 211 | ), |
||
| 212 | ), |
||
| 213 | ), |
||
| 214 | 'remark' => 'remark', |
||
| 215 | 'barcode' => 'BARCODE', |
||
| 216 | ); |
||
| 217 | $expectedDocument = self::createDomDocument(); |
||
| 218 | $box = $expectedDocument->createElement('box'); |
||
| 219 | $expectedDocument->appendChild($box); |
||
| 220 | $sender = $expectedDocument->createElement('sender'); |
||
| 221 | foreach ($data['sender'] as $key => $value) { |
||
| 222 | $key = 'common:' . $key; |
||
| 223 | if ($key == 'common:address') { |
||
| 224 | $address = $expectedDocument->createElement($key); |
||
| 225 | foreach ($value as $key2 => $value2) { |
||
| 226 | $key2 = 'common:' . $key2; |
||
| 227 | $address->appendChild( |
||
| 228 | $expectedDocument->createElement($key2, $value2) |
||
| 229 | ); |
||
| 230 | } |
||
| 231 | $sender->appendChild($address); |
||
| 232 | } else { |
||
| 233 | $sender->appendChild( |
||
| 234 | $expectedDocument->createElement($key, $value) |
||
| 235 | ); |
||
| 236 | } |
||
| 237 | } |
||
| 238 | $nationalBox = $expectedDocument->createElement('internationalBox'); |
||
| 239 | $atHome = $expectedDocument->createElement('international:international'); |
||
| 240 | $nationalBox->appendChild($atHome); |
||
| 241 | $atHome->appendChild( |
||
| 242 | $expectedDocument->createElement( |
||
| 243 | 'international:product', |
||
| 244 | $data['internationalBox']['international']['product'] |
||
| 245 | ) |
||
| 246 | ); |
||
| 247 | $receiver = $expectedDocument->createElement('international:receiver'); |
||
| 248 | $atHome->appendChild($receiver); |
||
| 249 | foreach ($data['internationalBox']['international']['receiver'] as $key => $value) { |
||
| 250 | $key = 'common:' . $key; |
||
| 251 | if ($key == 'common:address') { |
||
| 252 | $address = $expectedDocument->createElement($key); |
||
| 253 | foreach ($value as $key2 => $value2) { |
||
| 254 | $key2 = 'common:' . $key2; |
||
| 255 | $address->appendChild( |
||
| 256 | $expectedDocument->createElement($key2, $value2) |
||
| 257 | ); |
||
| 258 | } |
||
| 259 | $receiver->appendChild($address); |
||
| 260 | } else { |
||
| 261 | $receiver->appendChild( |
||
| 262 | $expectedDocument->createElement($key, $value) |
||
| 263 | ); |
||
| 264 | } |
||
| 265 | } |
||
| 266 | $box->appendChild($sender); |
||
| 267 | $box->appendChild($nationalBox); |
||
| 268 | $box->appendChild($expectedDocument->createElement('remark', $data['remark'])); |
||
| 269 | $box->appendChild($expectedDocument->createElement('barcode', $data['barcode'])); |
||
| 270 | |||
| 271 | $actualDocument = self::createDomDocument(); |
||
| 272 | $address = new Address( |
||
| 273 | $data['sender']['address']['streetName'], |
||
| 274 | $data['sender']['address']['number'], |
||
| 275 | $data['sender']['address']['box'], |
||
| 276 | $data['sender']['address']['postalCode'], |
||
| 277 | $data['sender']['address']['locality'], |
||
| 278 | $data['sender']['address']['countryCode'] |
||
| 279 | ); |
||
| 280 | |||
| 281 | $sender = new Sender(); |
||
| 282 | $sender->setName($data['sender']['name']); |
||
| 283 | $sender->setCompany($data['sender']['company']); |
||
| 284 | $sender->setAddress($address); |
||
| 285 | $sender->setEmailAddress($data['sender']['emailAddress']); |
||
| 286 | $sender->setPhoneNumber($data['sender']['phoneNumber']); |
||
| 287 | |||
| 288 | $address = new Address( |
||
| 289 | $data['internationalBox']['international']['receiver']['address']['streetName'], |
||
| 290 | $data['internationalBox']['international']['receiver']['address']['number'], |
||
| 291 | null, |
||
| 292 | $data['internationalBox']['international']['receiver']['address']['postalCode'], |
||
| 293 | $data['internationalBox']['international']['receiver']['address']['locality'], |
||
| 294 | $data['internationalBox']['international']['receiver']['address']['countryCode'] |
||
| 295 | ); |
||
| 296 | |||
| 297 | $receiver = new Receiver(); |
||
| 298 | $receiver->setAddress($address); |
||
| 299 | $receiver->setName($data['internationalBox']['international']['receiver']['name']); |
||
| 300 | $receiver->setCompany($data['internationalBox']['international']['receiver']['company']); |
||
| 301 | $receiver->setPhoneNumber($data['internationalBox']['international']['receiver']['phoneNumber']); |
||
| 302 | $receiver->setEmailAddress($data['internationalBox']['international']['receiver']['emailAddress']); |
||
| 303 | |||
| 304 | $international = new International(); |
||
| 305 | $international->setProduct($data['internationalBox']['international']['product']); |
||
| 306 | $international->setReceiver($receiver); |
||
| 307 | |||
| 308 | $box = new Box(); |
||
| 309 | $box->setSender($sender); |
||
| 310 | $box->setInternationalBox($international); |
||
| 311 | $box->setRemark($data['remark']); |
||
| 312 | $box->setBarcode($data['barcode']); |
||
| 313 | |||
| 314 | $actualDocument->appendChild( |
||
| 315 | $box->toXML($actualDocument, null) |
||
| 316 | ); |
||
| 317 | |||
| 318 | $this->assertSame($expectedDocument->saveXML(), $actualDocument->saveXML()); |
||
| 319 | } |
||
| 341 |
The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g.
excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths