Form::setToName()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 5
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 2
c 1
b 0
f 0
dl 0
loc 5
rs 10
cc 1
nc 1
nop 1
1
<?php
2
3
declare(strict_types=1);
4
5
namespace AbterPhp\Contact\Domain\Entities;
6
7
use AbterPhp\Framework\Domain\Entities\IStringerEntity;
8
9
class Form implements IStringerEntity
10
{
11
    /** @var string */
12
    protected $id;
13
14
    /** @var string */
15
    protected $name;
16
17
    /** @var string */
18
    protected $identifier;
19
20
    /** @var string */
21
    protected $toName;
22
23
    /** @var string */
24
    protected $toEmail;
25
26
    /** @var string */
27
    protected $successUrl;
28
29
    /** @var string */
30
    protected $failureUrl;
31
32
    /** @var int */
33
    protected $maxBodyLength;
34
35
    /**
36
     * @param string $id
37
     * @param string $name
38
     * @param string $identifier
39
     * @param string $toName
40
     * @param string $toEmail
41
     * @param string $successUrl
42
     * @param string $failureUrl
43
     * @param int    $maxBodyLength
44
     */
45
    public function __construct(
46
        string $id,
47
        string $name,
48
        string $identifier,
49
        string $toName,
50
        string $toEmail,
51
        string $successUrl,
52
        string $failureUrl,
53
        int $maxBodyLength
54
    ) {
55
        $this->id            = $id;
56
        $this->name          = $name;
57
        $this->identifier    = $identifier;
58
        $this->toName        = $toName;
59
        $this->toEmail       = $toEmail;
60
        $this->successUrl    = $successUrl;
61
        $this->failureUrl    = $failureUrl;
62
        $this->maxBodyLength = $maxBodyLength;
63
    }
64
65
    /**
66
     * @return string
67
     */
68
    public function getId()
69
    {
70
        return $this->id;
71
    }
72
73
    /**
74
     * @param string $id
75
     */
76
    public function setId($id)
77
    {
78
        $this->id = $id;
79
    }
80
81
    /**
82
     * @return string
83
     */
84
    public function getIdentifier(): string
85
    {
86
        return $this->identifier;
87
    }
88
89
    /**
90
     * @return string
91
     */
92
    public function getName(): string
93
    {
94
        return $this->name;
95
    }
96
97
    /**
98
     * @param string $name
99
     *
100
     * @return $this
101
     */
102
    public function setName(string $name): Form
103
    {
104
        $this->name = $name;
105
106
        return $this;
107
    }
108
109
    /**
110
     * @param string $identifier
111
     *
112
     * @return $this
113
     */
114
    public function setIdentifier(string $identifier): Form
115
    {
116
        $this->identifier = $identifier;
117
118
        return $this;
119
    }
120
121
    /**
122
     * @return string
123
     */
124
    public function getToName(): string
125
    {
126
        return $this->toName;
127
    }
128
129
    /**
130
     * @param string $toName
131
     *
132
     * @return $this
133
     */
134
    public function setToName(string $toName): Form
135
    {
136
        $this->toName = $toName;
137
138
        return $this;
139
    }
140
141
    /**
142
     * @return string
143
     */
144
    public function getToEmail(): string
145
    {
146
        return $this->toEmail;
147
    }
148
149
    /**
150
     * @param string $toEmail
151
     *
152
     * @return $this
153
     */
154
    public function setToEmail(string $toEmail): Form
155
    {
156
        $this->toEmail = $toEmail;
157
158
        return $this;
159
    }
160
161
    /**
162
     * @return string
163
     */
164
    public function getSuccessUrl(): string
165
    {
166
        return $this->successUrl;
167
    }
168
169
    /**
170
     * @param string $successUrl
171
     *
172
     * @return $this
173
     */
174
    public function setSuccessUrl(string $successUrl): Form
175
    {
176
        $this->successUrl = $successUrl;
177
178
        return $this;
179
    }
180
181
    /**
182
     * @return string
183
     */
184
    public function getFailureUrl(): string
185
    {
186
        return $this->failureUrl;
187
    }
188
189
    /**
190
     * @param string $failureUrl
191
     *
192
     * @return $this
193
     */
194
    public function setFailureUrl(string $failureUrl): Form
195
    {
196
        $this->failureUrl = $failureUrl;
197
198
        return $this;
199
    }
200
201
    /**
202
     * @return int
203
     */
204
    public function getMaxBodyLength(): int
205
    {
206
        return $this->maxBodyLength;
207
    }
208
209
    /**
210
     * @param int $maxBodyLength
211
     *
212
     * @return $this
213
     */
214
    public function setMaxBodyLength(int $maxBodyLength): Form
215
    {
216
        $this->maxBodyLength = $maxBodyLength;
217
218
        return $this;
219
    }
220
221
    /**
222
     * @return string
223
     */
224
    public function __toString(): string
225
    {
226
        return $this->getIdentifier();
227
    }
228
229
    /**
230
     * @return array|null
231
     */
232
    public function toData(): ?array
233
    {
234
        return [
235
            'id'              => $this->getId(),
236
            'name'            => $this->getName(),
237
            'identifier'      => $this->getIdentifier(),
238
            'to_name'         => $this->getToName(),
239
            'to_email'        => $this->getToEmail(),
240
            'success_url'     => $this->getSuccessUrl(),
241
            'failure_url'     => $this->getFailureUrl(),
242
            'max_body_length' => $this->getMaxBodyLength(),
243
        ];
244
    }
245
246
    /**
247
     * @return string
248
     */
249
    public function toJSON(): string
250
    {
251
        return json_encode($this->toData());
252
    }
253
}
254