Completed
Push — master ( afa46a...04583c )
by Joachim
02:00
created

Gateway::createCustomerInfo()   A

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
10
final class Gateway extends PaymentRequestPayloadGenerator
11
{
12
    public function createOrderLine(
13
        string $description,
14
        string $itemId,
15
        string $quantity,
16
        float $unitPrice,
17
        float $taxPercent = null,
18
        string $goodsType = null
19
    ): OrderLinePayload {
20
        return parent::createOrderLine($description, $itemId, $quantity, $unitPrice, $taxPercent,
21
            $goodsType);
22
    }
23
24
    public function createCustomerInfo(
25
        string $billingFirstName,
26
        string $billingLastName,
27
        string $billingAddress,
28
        string $billingPostal,
29
        string $billingCity,
30
        string $billingCountry,
31
        string $shippingFirstName,
32
        string $shippingLastName,
33
        string $shippingAddress,
34
        string $shippingPostal,
35
        string $shippingCity,
36
        string $shippingCountry
37
    ): CustomerInfoPayload {
38
        return parent::createCustomerInfo($billingFirstName, $billingLastName, $billingAddress, $billingPostal,
39
            $billingCity, $billingCountry, $shippingFirstName, $shippingLastName, $shippingAddress, $shippingPostal,
40
            $shippingCity, $shippingCountry);
41
    }
42
43
    public function createConfig(
44
        string $callbackForm,
45
        string $callbackOk,
46
        string $callbackFail,
47
        string $callbackRedirect,
48
        string $callbackOpen,
49
        string $callbackNotification
50
    ): ConfigPayload {
51
        return parent::createConfig($callbackForm, $callbackOk, $callbackFail, $callbackRedirect, $callbackOpen,
52
            $callbackNotification);
53
    }
54
}
55