| Conditions | 1 |
| Paths | 1 |
| Total Lines | 69 |
| Code Lines | 63 |
| 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 |
||
| 10 | public function testGettersSetters() |
||
| 11 | { |
||
| 12 | $payment = $this->getPayment(); |
||
| 13 | |||
| 14 | $created = \DateTimeImmutable::createFromFormat('Y-m-d H:i:s', '2017-10-01 04:00:00'); |
||
| 15 | $updated = \DateTimeImmutable::createFromFormat('Y-m-d H:i:s', '2017-10-01 04:00:01'); |
||
| 16 | |||
| 17 | $payment |
||
| 18 | ->setId(1) |
||
| 19 | ->setAltapayId('altapayid') |
||
| 20 | ->setCardStatus('cardstatus') |
||
| 21 | ->setCreditCardToken('cctoken') |
||
| 22 | ->setCreditCardMaskedPan('ccmaskedpan') |
||
| 23 | ->setThreeDSecureResult('3dres') |
||
| 24 | ->setLiableForChargeback('liable') |
||
| 25 | ->setBlacklistToken('blacklisttoken') |
||
| 26 | ->setShop('shop') |
||
| 27 | ->setTerminal('terminal') |
||
| 28 | ->setTransactionStatus('transactionstatus') |
||
| 29 | ->setReasonCode('reasoncode') |
||
| 30 | ->setMerchantCurrency(208) |
||
| 31 | ->setMerchantCurrencyAlpha('DKK') |
||
| 32 | ->setCardHolderCurrency(700) |
||
| 33 | ->setCardHolderCurrencyAlpha('EUR') |
||
| 34 | ->setReservedAmount(250.5) |
||
| 35 | ->setCapturedAmount(125.5) |
||
| 36 | ->setRefundedAmount(300.4) |
||
| 37 | ->setRecurringDefaultAmount(400.9) |
||
| 38 | ->setCreatedDate($created) |
||
| 39 | ->setUpdatedDate($updated) |
||
| 40 | ->setPaymentNature('paymentnature') |
||
| 41 | ->setSupportsRefunds(false) |
||
| 42 | ->setSupportsRelease(false) |
||
| 43 | ->setSupportsMultipleCaptures(true) |
||
| 44 | ->setSupportsMultipleRefunds(true) |
||
| 45 | ->setFraudRiskScore(13.37) |
||
| 46 | ->setFraudExplanation('fraudexplanation') |
||
| 47 | ; |
||
| 48 | |||
| 49 | $this->assertSame(1, $payment->getId()); |
||
| 50 | $this->assertSame('altapayid', $payment->getAltapayId()); |
||
| 51 | $this->assertSame('cardstatus', $payment->getCardStatus()); |
||
| 52 | $this->assertSame('cctoken', $payment->getCreditCardToken()); |
||
| 53 | $this->assertSame('ccmaskedpan', $payment->getCreditCardMaskedPan()); |
||
| 54 | $this->assertSame('3dres', $payment->getThreeDSecureResult()); |
||
| 55 | $this->assertSame('liable', $payment->getLiableForChargeback()); |
||
| 56 | $this->assertSame('blacklisttoken', $payment->getBlacklistToken()); |
||
| 57 | $this->assertSame('shop', $payment->getShop()); |
||
| 58 | $this->assertSame('terminal', $payment->getTerminal()); |
||
| 59 | $this->assertSame('transactionstatus', $payment->getTransactionStatus()); |
||
| 60 | $this->assertSame('reasoncode', $payment->getReasonCode()); |
||
| 61 | $this->assertSame(208, $payment->getMerchantCurrency()); |
||
| 62 | $this->assertSame('DKK', $payment->getMerchantCurrencyAlpha()); |
||
| 63 | $this->assertSame(700, $payment->getCardHolderCurrency()); |
||
| 64 | $this->assertSame('EUR', $payment->getCardHolderCurrencyAlpha()); |
||
| 65 | $this->assertSame(250.5, $payment->getReservedAmount()); |
||
| 66 | $this->assertSame(125.5, $payment->getCapturedAmount()); |
||
| 67 | $this->assertSame(300.4, $payment->getRefundedAmount()); |
||
| 68 | $this->assertSame(400.9, $payment->getRecurringDefaultAmount()); |
||
| 69 | $this->assertSame($created, $payment->getCreatedDate()); |
||
| 70 | $this->assertSame($updated, $payment->getUpdatedDate()); |
||
| 71 | $this->assertSame('paymentnature', $payment->getPaymentNature()); |
||
| 72 | $this->assertSame(false, $payment->getSupportsRefunds()); |
||
| 73 | $this->assertSame(false, $payment->getSupportsRelease()); |
||
| 74 | $this->assertSame(true, $payment->getSupportsMultipleCaptures()); |
||
| 75 | $this->assertSame(true, $payment->getSupportsMultipleRefunds()); |
||
| 76 | $this->assertSame(13.37, $payment->getFraudRiskScore()); |
||
| 77 | $this->assertSame('fraudexplanation', $payment->getFraudExplanation()); |
||
| 78 | } |
||
| 79 | |||
| 88 |