| Conditions | 3 |
| Paths | 4 |
| Total Lines | 59 |
| Code Lines | 38 |
| 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 |
||
| 28 | public function testToXML() |
||
| 29 | { |
||
| 30 | $data = array( |
||
| 31 | 'cod' => array( |
||
| 32 | 'codAmount' => 1251, |
||
| 33 | 'iban' => 'BE19210023508812', |
||
| 34 | 'bic' => 'GEBABEBB', |
||
| 35 | ), |
||
| 36 | ); |
||
| 37 | |||
| 38 | $expectedDocument = self::createDomDocument(); |
||
| 39 | $cod = $expectedDocument->createElement('common:cod'); |
||
| 40 | foreach ($data['cod'] as $key => $value) { |
||
| 41 | $cod->appendChild( |
||
| 42 | $expectedDocument->createElement('common:' . $key, $value) |
||
| 43 | ); |
||
| 44 | } |
||
| 45 | $expectedDocument->appendChild($cod); |
||
| 46 | |||
| 47 | $actualDocument = self::createDomDocument(); |
||
| 48 | $cashOnDelivery = new CashOnDelivery( |
||
| 49 | $data['cod']['codAmount'], |
||
| 50 | $data['cod']['iban'], |
||
| 51 | $data['cod']['bic'] |
||
| 52 | ); |
||
| 53 | $actualDocument->appendChild( |
||
| 54 | $cashOnDelivery->toXML($actualDocument) |
||
| 55 | ); |
||
| 56 | |||
| 57 | $this->assertEquals($expectedDocument->saveXML(), $actualDocument->saveXML()); |
||
| 58 | |||
| 59 | $data = array( |
||
| 60 | 'cod' => array( |
||
| 61 | 'codAmount' => 1251, |
||
| 62 | 'iban' => 'BE19210023508812', |
||
| 63 | 'bic' => 'GEBABEBB', |
||
| 64 | ), |
||
| 65 | ); |
||
| 66 | |||
| 67 | $expectedDocument = self::createDomDocument(); |
||
| 68 | $cod = $expectedDocument->createElement('foo:cod'); |
||
| 69 | foreach ($data['cod'] as $key => $value) { |
||
| 70 | $cod->appendChild( |
||
| 71 | $expectedDocument->createElement('foo:' . $key, $value) |
||
| 72 | ); |
||
| 73 | } |
||
| 74 | $expectedDocument->appendChild($cod); |
||
| 75 | |||
| 76 | $actualDocument = self::createDomDocument(); |
||
| 77 | $cashOnDelivery = new CashOnDelivery( |
||
| 78 | $data['cod']['codAmount'], |
||
| 79 | $data['cod']['iban'], |
||
| 80 | $data['cod']['bic'] |
||
| 81 | ); |
||
| 82 | $actualDocument->appendChild( |
||
| 83 | $cashOnDelivery->toXML($actualDocument, 'foo') |
||
| 84 | ); |
||
| 85 | |||
| 86 | $this->assertSame($expectedDocument->saveXML(), $actualDocument->saveXML()); |
||
| 87 | } |
||
| 89 |
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