Conditions | 7 |
Paths | 16 |
Total Lines | 139 |
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 |
||
35 | public function testNationalToXML() |
||
36 | { |
||
37 | $data = array( |
||
38 | 'sender' => array( |
||
39 | 'name' => 'Tijs Verkoyen', |
||
40 | 'company' => 'Sumo Coders', |
||
41 | 'address' => array( |
||
42 | 'streetName' => 'Afrikalaan', |
||
43 | 'number' => '289', |
||
44 | 'box' => '3', |
||
45 | 'postalCode' => '9000', |
||
46 | 'locality' => 'Gent', |
||
47 | 'countryCode' => 'BE', |
||
48 | ), |
||
49 | 'emailAddress' => '[email protected]', |
||
50 | 'phoneNumber' => '+32 9 395 02 51', |
||
51 | ), |
||
52 | 'nationalBox' => array( |
||
53 | 'atHome' => array( |
||
54 | 'product' => 'bpack 24h Pro', |
||
55 | 'weight' => 2000, |
||
56 | 'receiver' => array( |
||
57 | 'name' => 'Tijs Verkoyen', |
||
58 | 'company' => 'Sumo Coders', |
||
59 | 'address' => array( |
||
60 | 'streetName' => 'Kerkstraat', |
||
61 | 'number' => '108', |
||
62 | 'postalCode' => '9050', |
||
63 | 'locality' => 'Gentbrugge', |
||
64 | 'countryCode' => 'BE', |
||
65 | ), |
||
66 | 'emailAddress' => '[email protected]', |
||
67 | 'phoneNumber' => '+32 9 395 02 51', |
||
68 | ), |
||
69 | ), |
||
70 | ), |
||
71 | 'remark' => 'remark', |
||
72 | 'barcode' => 'BARCODE', |
||
73 | ); |
||
74 | |||
75 | $expectedDocument = self::createDomDocument(); |
||
76 | $box = $expectedDocument->createElement('box'); |
||
77 | $expectedDocument->appendChild($box); |
||
78 | $sender = $expectedDocument->createElement('sender'); |
||
79 | foreach ($data['sender'] as $key => $value) { |
||
80 | $key = 'common:' . $key; |
||
81 | if ($key == 'common:address') { |
||
82 | $address = $expectedDocument->createElement($key); |
||
83 | foreach ($value as $key2 => $value2) { |
||
84 | $key2 = 'common:' . $key2; |
||
85 | $address->appendChild( |
||
86 | $expectedDocument->createElement($key2, $value2) |
||
87 | ); |
||
88 | } |
||
89 | $sender->appendChild($address); |
||
90 | } else { |
||
91 | $sender->appendChild( |
||
92 | $expectedDocument->createElement($key, $value) |
||
93 | ); |
||
94 | } |
||
95 | } |
||
96 | $nationalBox = $expectedDocument->createElement('nationalBox'); |
||
97 | $atHome = $expectedDocument->createElement('atHome'); |
||
98 | $nationalBox->appendChild($atHome); |
||
99 | $atHome->appendChild($expectedDocument->createElement('product', $data['nationalBox']['atHome']['product'])); |
||
100 | $atHome->appendChild($expectedDocument->createElement('weight', $data['nationalBox']['atHome']['weight'])); |
||
101 | $receiver = $expectedDocument->createElement('receiver'); |
||
102 | $atHome->appendChild($receiver); |
||
103 | foreach ($data['nationalBox']['atHome']['receiver'] as $key => $value) { |
||
104 | $key = 'common:' . $key; |
||
105 | if ($key == 'common:address') { |
||
106 | $address = $expectedDocument->createElement($key); |
||
107 | foreach ($value as $key2 => $value2) { |
||
108 | $key2 = 'common:' . $key2; |
||
109 | $address->appendChild( |
||
110 | $expectedDocument->createElement($key2, $value2) |
||
111 | ); |
||
112 | } |
||
113 | $receiver->appendChild($address); |
||
114 | } else { |
||
115 | $receiver->appendChild( |
||
116 | $expectedDocument->createElement($key, $value) |
||
117 | ); |
||
118 | } |
||
119 | } |
||
120 | $box->appendChild($sender); |
||
121 | $box->appendChild($nationalBox); |
||
122 | $box->appendChild($expectedDocument->createElement('remark', $data['remark'])); |
||
123 | $box->appendChild($expectedDocument->createElement('barcode', $data['barcode'])); |
||
124 | |||
125 | $actualDocument = self::createDomDocument(); |
||
126 | $address = new Address( |
||
127 | $data['sender']['address']['streetName'], |
||
128 | $data['sender']['address']['number'], |
||
129 | $data['sender']['address']['box'], |
||
130 | $data['sender']['address']['postalCode'], |
||
131 | $data['sender']['address']['locality'], |
||
132 | $data['sender']['address']['countryCode'] |
||
133 | ); |
||
134 | |||
135 | $sender = new Sender(); |
||
136 | $sender->setName($data['sender']['name']); |
||
137 | $sender->setCompany($data['sender']['company']); |
||
138 | $sender->setAddress($address); |
||
139 | $sender->setEmailAddress($data['sender']['emailAddress']); |
||
140 | $sender->setPhoneNumber($data['sender']['phoneNumber']); |
||
141 | |||
142 | $address = new Address( |
||
143 | $data['nationalBox']['atHome']['receiver']['address']['streetName'], |
||
144 | $data['nationalBox']['atHome']['receiver']['address']['number'], |
||
145 | null, |
||
146 | $data['nationalBox']['atHome']['receiver']['address']['postalCode'], |
||
147 | $data['nationalBox']['atHome']['receiver']['address']['locality'], |
||
148 | $data['nationalBox']['atHome']['receiver']['address']['countryCode'] |
||
149 | ); |
||
150 | |||
151 | $receiver = new Receiver(); |
||
152 | $receiver->setAddress($address); |
||
153 | $receiver->setName($data['nationalBox']['atHome']['receiver']['name']); |
||
154 | $receiver->setCompany($data['nationalBox']['atHome']['receiver']['company']); |
||
155 | $receiver->setPhoneNumber($data['nationalBox']['atHome']['receiver']['phoneNumber']); |
||
156 | $receiver->setEmailAddress($data['nationalBox']['atHome']['receiver']['emailAddress']); |
||
157 | |||
158 | $atHome = new AtHome(); |
||
159 | $atHome->setProduct($data['nationalBox']['atHome']['product']); |
||
160 | $atHome->setWeight($data['nationalBox']['atHome']['weight']); |
||
161 | $atHome->setReceiver($receiver); |
||
162 | |||
163 | $box = new Box(); |
||
164 | $box->setSender($sender); |
||
165 | $box->setNationalBox($atHome); |
||
166 | $box->setRemark($data['remark']); |
||
167 | $box->setBarcode($data['barcode']); |
||
168 | |||
169 | $actualDocument->appendChild( |
||
170 | $box->toXML($actualDocument, null) |
||
171 | ); |
||
172 | |||
173 | $this->assertSame($expectedDocument->saveXML(), $actualDocument->saveXML()); |
||
174 | } |
||
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