PaypalService::__construct()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 18
Code Lines 8

Duplication

Lines 0
Ratio 0 %

Importance

Changes 3
Bugs 0 Features 1
Metric Value
cc 1
eloc 8
c 3
b 0
f 1
nc 1
nop 8
dl 0
loc 18
rs 10

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 App\Service;
4
5
use App\Service\Paypal\BillingAgreementService;
6
use App\Service\Paypal\IdentityService;
7
use App\Service\Paypal\InvoiceService;
8
use App\Service\Paypal\PaymentService;
9
use App\Service\Paypal\PayoutService;
10
use App\Service\Paypal\ReportingService;
11
use App\Service\Paypal\SessionService;
12
use App\Service\Paypal\VaultService;
13
14
/**
15
 * Class PaypalService
16
 * @package App\Service
17
 */
18
class PaypalService
19
{
20
    /**
21
     * @var IdentityService
22
     */
23
    protected $identityService;
24
25
    /**
26
     * @var PaymentService
27
     */
28
    protected $paymentService;
29
30
    /**
31
     * @var PayoutService
32
     */
33
    protected $payoutService;
34
35
    /**
36
     * @var ReportingService
37
     */
38
    protected $reportingService;
39
40
    /**
41
     * @var InvoiceService
42
     */
43
    protected $invoiceService;
44
45
    /**
46
     * @var SessionService
47
     */
48
    protected $sessionService;
49
50
    /**
51
     * @var BillingAgreementService
52
     */
53
    protected $billingAgreementService;
54
55
    /**
56
     * @var VaultService
57
     */
58
    protected $vaultService;
59
60
    /**
61
     * PaypalService constructor.
62
     * @param IdentityService $identityService
63
     * @param PaymentService $paymentService
64
     * @param PayoutService $payoutService
65
     * @param ReportingService $reportingService
66
     * @param InvoiceService $invoiceService
67
     * @param SessionService $sessionService
68
     * @param BillingAgreementService $billingAgreementService
69
     */
70
    public function __construct(
71
        IdentityService $identityService,
72
        PaymentService $paymentService,
73
        PayoutService $payoutService,
74
        ReportingService $reportingService,
75
        InvoiceService $invoiceService,
76
        SessionService $sessionService,
77
        BillingAgreementService $billingAgreementService,
78
        VaultService $vaultService
79
    ) {
80
        $this->identityService = $identityService;
81
        $this->paymentService = $paymentService;
82
        $this->payoutService = $payoutService;
83
        $this->reportingService = $reportingService;
84
        $this->invoiceService = $invoiceService;
85
        $this->sessionService = $sessionService;
86
        $this->billingAgreementService = $billingAgreementService;
87
        $this->vaultService = $vaultService;
88
    }
89
90
    /**
91
     * @return IdentityService
92
     */
93
    public function getIdentityService(): IdentityService
94
    {
95
        return $this->identityService;
96
    }
97
98
    /**
99
     * @return PaymentService
100
     */
101
    public function getPaymentService(): PaymentService
102
    {
103
        return $this->paymentService;
104
    }
105
106
    /**
107
     * @return PayoutService
108
     */
109
    public function getPayoutService(): PayoutService
110
    {
111
        return $this->payoutService;
112
    }
113
114
    /**
115
     * @return ReportingService
116
     */
117
    public function getReportingService(): ReportingService
118
    {
119
        return $this->reportingService;
120
    }
121
122
    /**
123
     * @return InvoiceService
124
     */
125
    public function getInvoiceService(): InvoiceService
126
    {
127
        return $this->invoiceService;
128
    }
129
130
    /**
131
     * @return SessionService
132
     */
133
    public function getSessionService(): SessionService
134
    {
135
        return $this->sessionService;
136
    }
137
138
    /**
139
     * @return BillingAgreementService
140
     */
141
    public function getBillingAgreementService(): BillingAgreementService
142
    {
143
        return $this->billingAgreementService;
144
    }
145
146
    /**
147
     * @return VaultService
148
     */
149
    public function getVaultService(): VaultService
150
    {
151
        return $this->vaultService;
152
    }
153
}
154