ProcessPaymentCancelEvent::__construct()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 10
Code Lines 0

Duplication

Lines 0
Ratio 0 %

Importance

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

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
declare(strict_types=1);
4
5
/*
6
 * This file is part of the Extension "sf_event_mgt" for TYPO3 CMS.
7
 *
8
 * For the full copyright and license information, please read the
9
 * LICENSE.txt file that was distributed with this source code.
10
 */
11
12
namespace DERHANSEN\SfEventMgt\Event;
13
14
use DERHANSEN\SfEventMgt\Controller\PaymentController;
15
use DERHANSEN\SfEventMgt\Domain\Model\Registration;
16
use Psr\Http\Message\ServerRequestInterface;
17
18
/**
19
 * This event is triggered before the payment cancel view is rendered. This event must be used to handle the
20
 * registration (e.g. update/delete) in case of the payment process is cancelled.
21
 */
22
final class ProcessPaymentCancelEvent
23
{
24
    public function __construct(
25
        private array $variables,
26
        private readonly string $paymentMethod,
27
        private bool $updateRegistration,
28
        private bool $removeRegistration,
29
        private readonly Registration $registration,
30
        private readonly array $getVariables,
31
        private readonly PaymentController $paymentController,
32
        private readonly ServerRequestInterface $request
33
    ) {
34
    }
35
36
    public function getVariables(): array
37
    {
38
        return $this->variables;
39
    }
40
41
    public function getPaymentMethod(): string
42
    {
43
        return $this->paymentMethod;
44
    }
45
46
    public function getUpdateRegistration(): bool
47
    {
48
        return $this->updateRegistration;
49
    }
50
51
    public function getRemoveRegistration(): bool
52
    {
53
        return $this->removeRegistration;
54
    }
55
56
    public function getRegistration(): Registration
57
    {
58
        return $this->registration;
59
    }
60
61
    public function getGetVariables(): array
62
    {
63
        return $this->getVariables;
64
    }
65
66
    public function getPaymentController(): PaymentController
67
    {
68
        return $this->paymentController;
69
    }
70
71
    public function setVariables(array $variables): void
72
    {
73
        $this->variables = $variables;
74
    }
75
76
    public function setUpdateRegistration(bool $updateRegistration): void
77
    {
78
        $this->updateRegistration = $updateRegistration;
79
    }
80
81
    public function setRemoveRegistration(bool $removeRegistration): void
82
    {
83
        $this->removeRegistration = $removeRegistration;
84
    }
85
86
    public function getRequest(): ServerRequestInterface
87
    {
88
        return $this->request;
89
    }
90
}
91