Passed
Push — 6.x ( a8fd70...fc83ac )
by Torben
08:33
created

ModifyUserMessageSenderEvent::__construct()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 19
Code Lines 8

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 8
c 1
b 0
f 0
nc 1
nop 8
dl 0
loc 19
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
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\Domain\Model\Registration;
15
use DERHANSEN\SfEventMgt\Service\NotificationService;
16
17
/**
18
 * This event should be used to modify the sender data of a user message. Use the $type variable to distinguish
19
 * between the different types of messages
20
 */
21
final class ModifyUserMessageSenderEvent
22
{
23
    private string $senderName;
24
    private string $senderEmail;
25
    private string $replyToEmail;
26
    private Registration $registration;
27
    private int $type;
28
    private string $subject;
29
    private string $body;
30
    private NotificationService $notificationService;
31
32
    public function __construct(
33
        string $senderName,
34
        string $senderEmail,
35
        string $replyToEmail,
36
        Registration $registration,
37
        int $type,
38
        string $subject,
39
        string $body,
40
        NotificationService $notificationService
41
    ) {
42
        $this->senderName = $senderName;
43
        $this->senderEmail = $senderEmail;
44
        $this->replyToEmail = $replyToEmail;
45
        $this->registration = $registration;
46
        $this->type = $type;
47
        $this->subject = $subject;
48
        $this->body = $body;
49
50
        $this->notificationService = $notificationService;
51
    }
52
53
    public function getSenderName(): string
54
    {
55
        return $this->senderName;
56
    }
57
58
    public function getSenderEmail(): string
59
    {
60
        return $this->senderEmail;
61
    }
62
63
    public function getReplyToEmail(): string
64
    {
65
        return $this->replyToEmail;
66
    }
67
68
    public function getRegistration(): Registration
69
    {
70
        return $this->registration;
71
    }
72
73
    public function getType(): int
74
    {
75
        return $this->type;
76
    }
77
78
    public function getSubject(): string
79
    {
80
        return $this->subject;
81
    }
82
83
    public function setSubject(string $subject): void
84
    {
85
        $this->subject = $subject;
86
    }
87
88
    public function getBody(): string
89
    {
90
        return $this->body;
91
    }
92
93
    public function setBody(string $body): void
94
    {
95
        $this->body = $body;
96
    }
97
98
    public function getNotificationService(): NotificationService
99
    {
100
        return $this->notificationService;
101
    }
102
103
    public function setSenderName(string $senderName): void
104
    {
105
        $this->senderName = $senderName;
106
    }
107
108
    public function setSenderEmail(string $senderEmail): void
109
    {
110
        $this->senderEmail = $senderEmail;
111
    }
112
113
    public function setReplyToEmail(string $replyToEmail): void
114
    {
115
        $this->replyToEmail = $replyToEmail;
116
    }
117
}
118