|
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\Translation; |
|
11
|
|
|
|
|
12
|
|
|
use FAPI\PhraseApp\Model\CreatableFromArray; |
|
13
|
|
|
|
|
14
|
|
|
/** |
|
15
|
|
|
* @author Sascha-Oliver Prolic <[email protected]> |
|
16
|
|
|
*/ |
|
17
|
|
|
final class Translation implements CreatableFromArray |
|
18
|
|
|
{ |
|
19
|
|
|
/** |
|
20
|
|
|
* @var string |
|
21
|
|
|
*/ |
|
22
|
|
|
private $id; |
|
23
|
|
|
|
|
24
|
|
|
/** |
|
25
|
|
|
* @var string |
|
26
|
|
|
*/ |
|
27
|
|
|
private $content; |
|
28
|
|
|
|
|
29
|
|
|
/** |
|
30
|
|
|
* @var bool |
|
31
|
|
|
*/ |
|
32
|
|
|
private $unverified; |
|
33
|
|
|
|
|
34
|
|
|
/** |
|
35
|
|
|
* @var bool |
|
36
|
|
|
*/ |
|
37
|
|
|
private $excluded; |
|
38
|
|
|
|
|
39
|
|
|
/** |
|
40
|
|
|
* @var string |
|
41
|
|
|
*/ |
|
42
|
|
|
private $pluralSuffix; |
|
43
|
|
|
|
|
44
|
|
|
/** |
|
45
|
|
|
* @var Key |
|
46
|
|
|
*/ |
|
47
|
|
|
private $key; |
|
48
|
|
|
|
|
49
|
|
|
/** |
|
50
|
|
|
* @var string |
|
51
|
|
|
*/ |
|
52
|
|
|
private $createdAt; |
|
53
|
|
|
|
|
54
|
|
|
/** |
|
55
|
|
|
* @var string |
|
56
|
|
|
*/ |
|
57
|
|
|
private $updatedAt; |
|
58
|
|
|
|
|
59
|
|
|
/** |
|
60
|
|
|
* @var array |
|
61
|
|
|
*/ |
|
62
|
|
|
private $placeholders = []; |
|
63
|
|
|
|
|
64
|
|
|
/** |
|
65
|
|
|
* @var Locale |
|
66
|
|
|
*/ |
|
67
|
|
|
private $locale; |
|
68
|
|
|
|
|
69
|
|
|
/** |
|
70
|
|
|
* @param array $data |
|
71
|
|
|
* |
|
72
|
|
|
* @return Translation |
|
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['content'])) { |
|
82
|
|
|
$self->setContent($data['content']); |
|
83
|
|
|
} |
|
84
|
|
|
if (isset($data['unverified'])) { |
|
85
|
|
|
$self->setUnverified($data['unverified']); |
|
86
|
|
|
} |
|
87
|
|
|
if (isset($data['excluded'])) { |
|
88
|
|
|
$self->setExcluded($data['excluded']); |
|
89
|
|
|
} |
|
90
|
|
|
if (isset($data['plural_suffix'])) { |
|
91
|
|
|
$self->setPluralSuffix($data['plural_suffix']); |
|
92
|
|
|
} |
|
93
|
|
|
if (isset($data['key']) && is_array($data['key'])) { |
|
94
|
|
|
$self->setKey(Key::createFromArray($data['key'])); |
|
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['placeholders'])) { |
|
103
|
|
|
$self->setPlaceholders($data['placeholders']); |
|
104
|
|
|
} |
|
105
|
|
|
if (isset($data['locale']) && is_array($data['locale'])) { |
|
106
|
|
|
$self->setLocale(Locale::createFromArray($data['locale'])); |
|
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 getContent(): string |
|
123
|
|
|
{ |
|
124
|
|
|
return $this->content; |
|
125
|
|
|
} |
|
126
|
|
|
|
|
127
|
|
|
private function setContent(string $content) |
|
128
|
|
|
{ |
|
129
|
|
|
$this->content = $content; |
|
130
|
|
|
} |
|
131
|
|
|
|
|
132
|
|
|
public function isUnverified(): bool |
|
133
|
|
|
{ |
|
134
|
|
|
return $this->unverified; |
|
135
|
|
|
} |
|
136
|
|
|
|
|
137
|
|
|
private function setUnverified(bool $unverified) |
|
138
|
|
|
{ |
|
139
|
|
|
$this->unverified = $unverified; |
|
140
|
|
|
} |
|
141
|
|
|
|
|
142
|
|
|
public function isExcluded(): bool |
|
143
|
|
|
{ |
|
144
|
|
|
return $this->excluded; |
|
145
|
|
|
} |
|
146
|
|
|
|
|
147
|
|
|
private function setExcluded(bool $excluded) |
|
148
|
|
|
{ |
|
149
|
|
|
$this->excluded = $excluded; |
|
150
|
|
|
} |
|
151
|
|
|
|
|
152
|
|
|
public function getPluralSuffix(): string |
|
153
|
|
|
{ |
|
154
|
|
|
return $this->pluralSuffix; |
|
155
|
|
|
} |
|
156
|
|
|
|
|
157
|
|
|
private function setPluralSuffix(string $pluralSuffix) |
|
158
|
|
|
{ |
|
159
|
|
|
$this->pluralSuffix = $pluralSuffix; |
|
160
|
|
|
} |
|
161
|
|
|
|
|
162
|
|
|
public function getKey(): Key |
|
163
|
|
|
{ |
|
164
|
|
|
return $this->key; |
|
165
|
|
|
} |
|
166
|
|
|
|
|
167
|
|
|
private function setKey(Key $key) |
|
168
|
|
|
{ |
|
169
|
|
|
$this->key = $key; |
|
170
|
|
|
} |
|
171
|
|
|
|
|
172
|
|
|
public function getCreatedAt(): string |
|
173
|
|
|
{ |
|
174
|
|
|
return $this->createdAt; |
|
175
|
|
|
} |
|
176
|
|
|
|
|
177
|
|
|
private function setCreatedAt(string $createdAt) |
|
178
|
|
|
{ |
|
179
|
|
|
$this->createdAt = $createdAt; |
|
180
|
|
|
} |
|
181
|
|
|
|
|
182
|
|
|
public function getUpdatedAt(): string |
|
183
|
|
|
{ |
|
184
|
|
|
return $this->updatedAt; |
|
185
|
|
|
} |
|
186
|
|
|
|
|
187
|
|
|
private function setUpdatedAt(string $updatedAt) |
|
188
|
|
|
{ |
|
189
|
|
|
$this->updatedAt = $updatedAt; |
|
190
|
|
|
} |
|
191
|
|
|
|
|
192
|
|
|
public function getPlaceholders(): array |
|
193
|
|
|
{ |
|
194
|
|
|
return $this->placeholders; |
|
195
|
|
|
} |
|
196
|
|
|
|
|
197
|
|
|
private function setPlaceholders(array $placeholders) |
|
198
|
|
|
{ |
|
199
|
|
|
$this->placeholders = $placeholders; |
|
200
|
|
|
} |
|
201
|
|
|
|
|
202
|
|
|
public function getLocale(): Locale |
|
203
|
|
|
{ |
|
204
|
|
|
return $this->locale; |
|
205
|
|
|
} |
|
206
|
|
|
|
|
207
|
|
|
private function setLocale(Locale $locale) |
|
208
|
|
|
{ |
|
209
|
|
|
$this->locale = $locale; |
|
210
|
|
|
} |
|
211
|
|
|
} |
|
212
|
|
|
|