Issues (89)

src/Domain/ValueObject/Delegate.php (1 issue)

Severity
1
<?php
2
3
namespace ConferenceTools\Tickets\Domain\ValueObject;
4
5
use Doctrine\ORM\Mapping as ORM;
6
use JMS\Serializer\Annotation as JMS;
7
8
/**
9
 * Class Delegate
10
 * @package ConferenceTools\Tickets\Domain\ValueObject
11
 * @ORM\Embeddable()
12
 */
13
class Delegate
14
{
15
    /**
16
     * @var string
17
     * @ORM\Column(type="string")
18
     * @JMS\Type("string")
19
     */
20
    private $firstname;
21
    /**
22
     * @var string
23
     * @ORM\Column(type="string")
24
     * @JMS\Type("string")
25
     */
26
    private $lastname;
27
    /**
28
     * @var string
29
     * @ORM\Column(type="string")
30
     * @JMS\Type("string")
31
     */
32
    private $email;
33
    /**
34
     * @var string
35
     * @ORM\Column(type="string")
36
     * @JMS\Type("string")
37
     */
38
    private $company;
39
    /**
40
     * @var string
41
     * @ORM\Column(type="string")
42
     * @JMS\Type("string")
43
     */
44
    private $twitter;
45
    /**
46
     * @var string
47
     * @ORM\Column(type="string")
48
     * @JMS\Type("string")
49
     */
50
    private $requirements;
51
52
    /**
53
     * @var DelegateAdditionalInformation
54
     * @ORM\Column(type="json_object")
55
     * @JMS\Type("ConferenceTools\Tickets\Domain\ValueObject\DelegateAdditionalInformation")
56
     */
57
    private $additionalInformation;
58
59
    /**
60
     * Delegate constructor.
61
     * @param string $firstname
62
     * @param string $lastname
63
     * @param string $email
64
     * @param string $company
65
     * @param string $twitter
66
     * @param string $requirements
67
     */
68 7
    public function __construct(string $firstname, string $lastname, string $email, string $company, string $twitter, string $requirements)
69
    {
70 7
        $this->firstname = $firstname;
71 7
        $this->lastname = $lastname;
72 7
        $this->email = $email;
73 7
        $this->company = $company;
74 7
        $this->twitter = $twitter;
75 7
        $this->requirements = $requirements;
76 7
        $this->additionalInformation = new DelegateAdditionalInformation();
77 7
    }
78
79 6
    public static function emptyObject()
80
    {
81 6
        return new static('', '', '', '', '', '', '');
0 ignored issues
show
The call to ConferenceTools\Tickets\...Delegate::__construct() has too many arguments starting with ''. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

81
        return /** @scrutinizer ignore-call */ new static('', '', '', '', '', '', '');

This check compares calls to functions or methods with their respective definitions. If the call has more arguments than are defined, it raises an issue.

If a function is defined several times with a different number of parameters, the check may pick up the wrong definition and report false positives. One codebase where this has been known to happen is Wordpress. Please note the @ignore annotation hint above.

Loading history...
82
    }
83
84 2
    public static function fromArray(array $data)
85
    {
86 2
        $instance = new static(
87 2
            $data['firstname'],
88 2
            $data['lastname'],
89 2
            $data['email'],
90 2
            $data['company'],
91 2
            $data['twitter'],
92 2
            $data['requirements']
93
        );
94
95
        unset(
96 2
            $data['firstname'],
97 2
            $data['lastname'],
98 2
            $data['email'],
99 2
            $data['company'],
100 2
            $data['twitter'],
101 2
            $data['requirements']
102
        );
103
104 2
        foreach ($data as $questionHandle => $questionAnswer) {
105
            $instance->additionalInformation->addQuestion($questionHandle, $questionAnswer);
106
        }
107
108 2
        return $instance;
109
    }
110
111
    public function toArray()
112
    {
113
        $data = [
114
            'firstname' => $this->firstname,
115
            'lastname' => $this->lastname,
116
            'email' => $this->email,
117
            'company' => $this->company,
118
            'twitter' => $this->twitter,
119
            'requirements' => $this->requirements,
120
        ];
121
122
        foreach ($this->additionalInformation->getQuestions() as $question) {
123
            $data[$question->getHandle()] = $question->getAnswer();
124
        }
125
126
        return $data;
127
    }
128
129
    /**
130
     * @return string
131
     */
132 2
    public function getFirstname()
133
    {
134 2
        return $this->firstname;
135
    }
136
137
    /**
138
     * @return string
139
     */
140 2
    public function getLastname()
141
    {
142 2
        return $this->lastname;
143
    }
144
145
    /**
146
     * @return string
147
     */
148 2
    public function getEmail()
149
    {
150 2
        return $this->email;
151
    }
152
153
    /**
154
     * @return string
155
     */
156 2
    public function getCompany()
157
    {
158 2
        return $this->company;
159
    }
160
161
    /**
162
     * @return string
163
     */
164 2
    public function getTwitter()
165
    {
166 2
        return $this->twitter;
167
    }
168
169
    /**
170
     * @return string
171
     */
172 2
    public function getRequirements()
173
    {
174 2
        return $this->requirements;
175
    }
176
177
    /**
178
     * @return DelegateAdditionalInformation
179
     */
180
    public function getAdditionalInformation(): DelegateAdditionalInformation
181
    {
182
        return $this->additionalInformation;
183
    }
184
}
185