1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
declare(strict_types=1); |
4
|
|
|
|
5
|
|
|
/* |
6
|
|
|
* This software may be modified and distributed under the terms |
7
|
|
|
* of the MIT license. See the LICENSE file for details. |
8
|
|
|
*/ |
9
|
|
|
|
10
|
|
|
namespace FAPI\PhraseApp\Model\Key; |
11
|
|
|
|
12
|
|
|
use FAPI\PhraseApp\Model\CreatableFromArray; |
13
|
|
|
|
14
|
|
|
/** |
15
|
|
|
* @author Sascha-Oliver Prolic <[email protected]> |
16
|
|
|
*/ |
17
|
|
|
final class KeyCreated implements CreatableFromArray |
18
|
|
|
{ |
19
|
|
|
/** |
20
|
|
|
* @var string |
21
|
|
|
*/ |
22
|
|
|
private $id; |
23
|
|
|
|
24
|
|
|
/** |
25
|
|
|
* @var string |
26
|
|
|
*/ |
27
|
|
|
private $name; |
28
|
|
|
|
29
|
|
|
/** |
30
|
|
|
* @var string |
31
|
|
|
*/ |
32
|
|
|
private $description; |
33
|
|
|
|
34
|
|
|
/** |
35
|
|
|
* @var string |
36
|
|
|
*/ |
37
|
|
|
private $nameHash; |
38
|
|
|
|
39
|
|
|
/** |
40
|
|
|
* @var bool |
41
|
|
|
*/ |
42
|
|
|
private $plural; |
43
|
|
|
|
44
|
|
|
/** |
45
|
|
|
* @var string |
46
|
|
|
*/ |
47
|
|
|
private $namePlural; |
48
|
|
|
|
49
|
|
|
/** |
50
|
|
|
* @var string |
51
|
|
|
*/ |
52
|
|
|
private $createdAt; |
53
|
|
|
|
54
|
|
|
/** |
55
|
|
|
* @var string |
56
|
|
|
*/ |
57
|
|
|
private $updatedAt; |
58
|
|
|
|
59
|
|
|
/** |
60
|
|
|
* @var string |
61
|
|
|
*/ |
62
|
|
|
private $dataType; |
63
|
|
|
|
64
|
|
|
/** |
65
|
|
|
* @var array |
66
|
|
|
*/ |
67
|
|
|
private $tags = []; |
68
|
|
|
|
69
|
|
|
/** |
70
|
|
|
* @param array $data |
71
|
|
|
* |
72
|
|
|
* @return KeyCreated |
73
|
|
|
*/ |
74
|
|
|
public static function createFromArray(array $data) |
75
|
|
|
{ |
76
|
|
|
$self = new self(); |
77
|
|
|
|
78
|
|
|
if (isset($data['id'])) { |
79
|
|
|
$self->setId($data['id']); |
80
|
|
|
} |
81
|
|
|
if (isset($data['name'])) { |
82
|
|
|
$self->setName($data['name']); |
83
|
|
|
} |
84
|
|
|
if (isset($data['description'])) { |
85
|
|
|
$self->setDescription($data['description']); |
86
|
|
|
} |
87
|
|
|
if (isset($data['name_hash'])) { |
88
|
|
|
$self->setNameHash($data['name_hash']); |
89
|
|
|
} |
90
|
|
|
if (isset($data['plural'])) { |
91
|
|
|
$self->setPlural($data['plural']); |
92
|
|
|
} |
93
|
|
|
if (isset($data['name_plural'])) { |
94
|
|
|
$self->setNamePlural($data['name_plural']); |
95
|
|
|
} |
96
|
|
|
if (isset($data['created_at'])) { |
97
|
|
|
$self->setCreatedAt($data['created_at']); |
98
|
|
|
} |
99
|
|
|
if (isset($data['updated_at'])) { |
100
|
|
|
$self->setUpdatedAt($data['updated_at']); |
101
|
|
|
} |
102
|
|
|
if (isset($data['data_type'])) { |
103
|
|
|
$self->setDataType($data['data_type']); |
104
|
|
|
} |
105
|
|
|
if (isset($data['tags'])) { |
106
|
|
|
$self->setTags($data['tags']); |
107
|
|
|
} |
108
|
|
|
|
109
|
|
|
return $self; |
110
|
|
|
} |
111
|
|
|
|
112
|
|
|
public function getId(): string |
113
|
|
|
{ |
114
|
|
|
return $this->id; |
115
|
|
|
} |
116
|
|
|
|
117
|
|
|
private function setId(string $id) |
118
|
|
|
{ |
119
|
|
|
$this->id = $id; |
120
|
|
|
} |
121
|
|
|
|
122
|
|
|
public function getName(): string |
123
|
|
|
{ |
124
|
|
|
return $this->name; |
125
|
|
|
} |
126
|
|
|
|
127
|
|
|
private function setName(string $name) |
128
|
|
|
{ |
129
|
|
|
$this->name = $name; |
130
|
|
|
} |
131
|
|
|
|
132
|
|
|
public function isPlural(): bool |
133
|
|
|
{ |
134
|
|
|
return $this->plural; |
135
|
|
|
} |
136
|
|
|
|
137
|
|
|
private function setPlural(bool $plural) |
138
|
|
|
{ |
139
|
|
|
$this->plural = $plural; |
140
|
|
|
} |
141
|
|
|
|
142
|
|
|
public function getNamePlural(): string |
143
|
|
|
{ |
144
|
|
|
return $this->namePlural; |
145
|
|
|
} |
146
|
|
|
|
147
|
|
|
private function setNamePlural(string $namePlural) |
148
|
|
|
{ |
149
|
|
|
$this->namePlural = $namePlural; |
150
|
|
|
} |
151
|
|
|
|
152
|
|
|
public function getDataType(): string |
153
|
|
|
{ |
154
|
|
|
return $this->dataType; |
155
|
|
|
} |
156
|
|
|
|
157
|
|
|
private function setDataType(string $dataType) |
158
|
|
|
{ |
159
|
|
|
$this->dataType = $dataType; |
160
|
|
|
} |
161
|
|
|
|
162
|
|
|
public function getTags(): array |
163
|
|
|
{ |
164
|
|
|
return $this->tags; |
165
|
|
|
} |
166
|
|
|
|
167
|
|
|
private function setTags(array $tags) |
168
|
|
|
{ |
169
|
|
|
$this->tags = $tags; |
170
|
|
|
} |
171
|
|
|
|
172
|
|
|
public function getDescription(): string |
173
|
|
|
{ |
174
|
|
|
return $this->description; |
175
|
|
|
} |
176
|
|
|
|
177
|
|
|
private function setDescription(string $description) |
178
|
|
|
{ |
179
|
|
|
$this->description = $description; |
180
|
|
|
} |
181
|
|
|
|
182
|
|
|
public function getNameHash(): string |
183
|
|
|
{ |
184
|
|
|
return $this->nameHash; |
185
|
|
|
} |
186
|
|
|
|
187
|
|
|
private function setNameHash(string $nameHash) |
188
|
|
|
{ |
189
|
|
|
$this->nameHash = $nameHash; |
190
|
|
|
} |
191
|
|
|
|
192
|
|
|
public function getCreatedAt(): string |
193
|
|
|
{ |
194
|
|
|
return $this->createdAt; |
195
|
|
|
} |
196
|
|
|
|
197
|
|
|
private function setCreatedAt(string $createdAt) |
198
|
|
|
{ |
199
|
|
|
$this->createdAt = $createdAt; |
200
|
|
|
} |
201
|
|
|
|
202
|
|
|
public function getUpdatedAt(): string |
203
|
|
|
{ |
204
|
|
|
return $this->updatedAt; |
205
|
|
|
} |
206
|
|
|
|
207
|
|
|
private function setUpdatedAt(string $updatedAt) |
208
|
|
|
{ |
209
|
|
|
$this->updatedAt = $updatedAt; |
210
|
|
|
} |
211
|
|
|
} |
212
|
|
|
|