Gateway::createCustomerInfo()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 18
Code Lines 17

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 18
rs 9.4285
c 0
b 0
f 0
cc 1
eloc 17
nc 1
nop 12

How to fix   Many Parameters   

Many Parameters

Methods with many parameters are not only hard to understand, but their parameters also often become inconsistent when you need more, or different data.

There are several approaches to avoid long parameter lists:

1
<?php
2
3
namespace Loevgaard\DandomainAltapayBundle\Tests\PayloadGenerator\Fixture;
4
5
use Loevgaard\AltaPay\Payload\OrderLine as OrderLinePayload;
6
use Loevgaard\AltaPay\Payload\PaymentRequest\Config as ConfigPayload;
7
use Loevgaard\AltaPay\Payload\PaymentRequest\CustomerInfo as CustomerInfoPayload;
8
use Loevgaard\DandomainAltapayBundle\PayloadGenerator\PaymentRequestPayloadGenerator;
9
use Money\Money;
10
11
final class Gateway extends PaymentRequestPayloadGenerator
12
{
13
    public function createOrderLine(
14
        string $description,
15
        string $itemId,
16
        string $quantity,
17
        Money $unitPrice,
18
        float $taxPercent = null,
19
        string $goodsType = null
20
    ): OrderLinePayload {
21
        return parent::createOrderLine($description, $itemId, $quantity, $unitPrice, $taxPercent,
22
            $goodsType);
23
    }
24
25
    public function createCustomerInfo(
26
        string $billingFirstName,
27
        string $billingLastName,
28
        string $billingAddress,
29
        string $billingPostal,
30
        string $billingCity,
31
        string $billingCountry,
32
        string $shippingFirstName,
33
        string $shippingLastName,
34
        string $shippingAddress,
35
        string $shippingPostal,
36
        string $shippingCity,
37
        string $shippingCountry
38
    ): CustomerInfoPayload {
39
        return parent::createCustomerInfo($billingFirstName, $billingLastName, $billingAddress, $billingPostal,
40
            $billingCity, $billingCountry, $shippingFirstName, $shippingLastName, $shippingAddress, $shippingPostal,
41
            $shippingCity, $shippingCountry);
42
    }
43
44
    public function createConfig(
45
        string $callbackForm,
46
        string $callbackOk,
47
        string $callbackFail,
48
        string $callbackRedirect,
49
        string $callbackOpen,
50
        string $callbackNotification
51
    ): ConfigPayload {
52
        return parent::createConfig($callbackForm, $callbackOk, $callbackFail, $callbackRedirect, $callbackOpen,
53
            $callbackNotification);
54
    }
55
}
56