| Conditions | 11 |
| Paths | 16 |
| Total Lines | 63 |
| Code Lines | 48 |
| 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 |
||
| 176 | public function testEntries() |
||
| 177 | { |
||
| 178 | $messages = [ |
||
| 179 | $this->getV2Message(), |
||
| 180 | $this->getV3Message(), |
||
| 181 | $this->getV4Message(), |
||
| 182 | $this->getV2UltimateMessage(), |
||
| 183 | ]; |
||
| 184 | |||
| 185 | foreach ($messages as $message) { |
||
| 186 | $statements = $message->getRecords(); |
||
| 187 | |||
| 188 | $this->assertCount(1, $statements); |
||
| 189 | foreach ($statements as $statement) { |
||
| 190 | $entries = $statement->getEntries(); |
||
| 191 | $this->assertCount(1, $entries); |
||
| 192 | |||
| 193 | foreach ($entries as $entry) { |
||
| 194 | $this->assertEquals(885, $entry->getAmount()->getAmount()); |
||
| 195 | $this->assertEquals('EUR', $entry->getAmount()->getCurrency()->getCode()); |
||
| 196 | $this->assertEquals('2014-12-31', $entry->getBookingDate()->format('Y-m-d')); |
||
| 197 | $this->assertEquals('2015-01-02', $entry->getValueDate()->format('Y-m-d')); |
||
| 198 | |||
| 199 | $details = $entry->getTransactionDetails(); |
||
| 200 | $this->assertCount(1, $details); |
||
| 201 | foreach ($details as $detail) { |
||
| 202 | $parties = $detail->getRelatedParties(); |
||
| 203 | $this->assertCount(2, $parties); |
||
| 204 | |||
| 205 | foreach ($parties as $party) { |
||
| 206 | if ($party->getRelatedPartyType() instanceof DTO\Creditor) { |
||
| 207 | if ($party->getRelatedPartyType() instanceof DTO\UltimateCreditor) { |
||
| 208 | $this->assertEquals('CREDITOR NAME NM', $party->getRelatedPartyType()->getName()); |
||
| 209 | $this->assertEquals(["CREDITOR NAME", "CREDITOR ADD"], $party->getRelatedPartyType()->getAddress()->getAddressLines()); |
||
| 210 | } else { |
||
| 211 | $this->assertEquals('Company Name', $party->getRelatedPartyType()->getName()); |
||
| 212 | $this->assertEquals('NL', $party->getRelatedPartyType()->getAddress()->getCountry()); |
||
| 213 | $this->assertEquals([], $party->getRelatedPartyType()->getAddress()->getAddressLines()); |
||
| 214 | $this->assertEquals('NL56AGDH9619008421', (string) $party->getAccount()->getIdentification()); |
||
| 215 | } |
||
| 216 | } elseif ($party->getRelatedPartyType() instanceof DTO\Debtor) { |
||
| 217 | if ($party->getRelatedPartyType() instanceof DTO\UltimateDebtor) { |
||
| 218 | $this->assertEquals('DEBTOR NAME NM', $party->getRelatedPartyType()->getName()); |
||
| 219 | $this->assertEquals(["DEBTOR NAME", "DEBTOR ADD"], $party->getRelatedPartyType()->getAddress()->getAddressLines()); |
||
| 220 | } else { |
||
| 221 | $this->assertEquals('NAME NAME', $party->getRelatedPartyType()->getName()); |
||
| 222 | $this->assertEquals('NL', $party->getRelatedPartyType()->getAddress()->getCountry()); |
||
| 223 | $this->assertEquals(['ADDR ADDR 10', '2000 ANTWERPEN'], $party->getRelatedPartyType()->getAddress()->getAddressLines()); |
||
| 224 | $this->assertEquals('NL56AGDH9619008421', (string) $party->getAccount()->getIdentification()); |
||
| 225 | } |
||
| 226 | } |
||
| 227 | } |
||
| 228 | |||
| 229 | $references = $detail->getReferences(); |
||
| 230 | $this->assertCount(1, $references); |
||
| 231 | foreach ($references as $reference) { |
||
| 232 | $this->assertEquals('LegalSequenceNumber', $reference->getProprietaries()[0]->getType()); |
||
| 233 | $this->assertEquals('100', $reference->getProprietaries()[0]->getReference()); |
||
| 234 | $this->assertNull($reference->getMandateId()); |
||
| 235 | } |
||
| 236 | |||
| 237 | $remittanceInformation = $detail->getRemittanceInformation(); |
||
| 238 | $this->assertEquals('4654654654654654', $remittanceInformation->getCreditorReferenceInformation()->getRef()); |
||
| 239 | } |
||
| 274 |