1 | <?php |
||
22 | class Translation implements \JsonSerializable |
||
23 | { |
||
24 | /** |
||
25 | * @var string |
||
26 | * |
||
27 | * @ES\Id() |
||
28 | */ |
||
29 | private $id; |
||
30 | |||
31 | /** |
||
32 | * @var string |
||
33 | * |
||
34 | * @ES\Property(type="string", options={"index"="not_analyzed"}) |
||
35 | */ |
||
36 | private $domain; |
||
37 | |||
38 | /** |
||
39 | * @var Tag[] |
||
40 | * |
||
41 | * @ES\Embedded(class="ONGRTranslationsBundle:Tag", multiple=true) |
||
42 | */ |
||
43 | private $tags = []; |
||
44 | |||
45 | /** |
||
46 | * @var Message[] |
||
47 | * |
||
48 | * @ES\Embedded(class="ONGRTranslationsBundle:Message", multiple=true) |
||
49 | */ |
||
50 | private $messages = []; |
||
51 | |||
52 | /** |
||
53 | * @var string |
||
54 | * |
||
55 | * @ES\Property(type="string", options={"index"="not_analyzed"}) |
||
56 | */ |
||
57 | private $key; |
||
58 | |||
59 | /** |
||
60 | * @var string |
||
61 | * |
||
62 | * @ES\Property(type="string", options={"index"="not_analyzed"}) |
||
63 | */ |
||
64 | private $path; |
||
65 | |||
66 | /** |
||
67 | * @var string |
||
68 | * |
||
69 | * @ES\Property(type="string") |
||
70 | */ |
||
71 | private $format; |
||
72 | |||
73 | /** |
||
74 | * @var \DateTime |
||
75 | * |
||
76 | * @ES\Property(type="date") |
||
77 | */ |
||
78 | private $createdAt; |
||
79 | |||
80 | /** |
||
81 | * @var \DateTime |
||
82 | * |
||
83 | 4 | * @ES\Property(type="date") |
|
84 | */ |
||
85 | 4 | private $updatedAt; |
|
86 | 4 | ||
87 | 4 | /** |
|
88 | * Sets timestamps. |
||
89 | */ |
||
90 | public function __construct() |
||
91 | { |
||
92 | 4 | $this->tags = new Collection(); |
|
|
|||
93 | $this->messages = new Collection(); |
||
94 | 4 | $this->createdAt = new \DateTime(); |
|
95 | $this->updatedAt = new \DateTime(); |
||
96 | } |
||
97 | |||
98 | /** |
||
99 | * Sets document unique id. |
||
100 | 4 | * |
|
101 | * @param string $documentId |
||
102 | 4 | * |
|
103 | 4 | * @return $this |
|
104 | */ |
||
105 | public function setId($documentId) |
||
106 | { |
||
107 | $this->id = $documentId; |
||
108 | |||
109 | return $this; |
||
110 | } |
||
111 | |||
112 | /** |
||
113 | * Returns document id. |
||
114 | * |
||
115 | * @return string |
||
116 | */ |
||
117 | public function getId() |
||
118 | { |
||
119 | if (!$this->id) { |
||
120 | 2 | $this->setId(sha1($this->getDomain() . $this->getKey())); |
|
121 | } |
||
122 | 2 | ||
123 | return $this->id; |
||
124 | } |
||
125 | |||
126 | /** |
||
127 | * @return string |
||
128 | */ |
||
129 | public function getDomain() |
||
130 | { |
||
131 | return $this->domain; |
||
132 | } |
||
133 | |||
134 | /** |
||
135 | * @param string $domain |
||
136 | */ |
||
137 | public function setDomain($domain) |
||
138 | 4 | { |
|
139 | $this->domain = $domain; |
||
140 | 4 | } |
|
141 | |||
142 | /** |
||
143 | * Sets tags. |
||
144 | * |
||
145 | * @param Tag[]|Collection $tags |
||
146 | 3 | */ |
|
147 | public function setTags(Collection $tags = null) |
||
151 | |||
152 | /** |
||
153 | * Returns all tags. |
||
154 | * |
||
155 | * @return Tag[] |
||
156 | 1 | */ |
|
157 | public function getTags() |
||
161 | |||
162 | 1 | /** |
|
163 | * Adds a single tag. |
||
164 | * |
||
165 | * @param Tag $tag |
||
166 | */ |
||
167 | public function addTag($tag) |
||
171 | 4 | ||
172 | /** |
||
173 | * @return string |
||
174 | */ |
||
175 | public function getKey() |
||
179 | |||
180 | /** |
||
181 | * @param string $key |
||
182 | */ |
||
183 | public function setKey($key) |
||
187 | 1 | ||
188 | /** |
||
189 | * @param Message $message |
||
190 | */ |
||
191 | public function addMessage(Message $message) |
||
195 | |||
196 | /** |
||
197 | * @return Message[] |
||
198 | */ |
||
199 | public function getMessages() |
||
200 | 3 | { |
|
201 | return $this->messages; |
||
202 | 3 | } |
|
203 | 3 | ||
204 | /** |
||
205 | * @param Message[]|Collection $messages |
||
206 | */ |
||
207 | public function setMessages(Collection $messages = null) |
||
208 | 3 | { |
|
209 | $this->messages = $messages; |
||
210 | 3 | } |
|
211 | |||
212 | /** |
||
213 | * @return string |
||
214 | */ |
||
215 | public function getPath() |
||
219 | 3 | ||
220 | /** |
||
221 | * @param string $path |
||
222 | */ |
||
223 | public function setPath($path) |
||
227 | |||
228 | /** |
||
229 | * @return string |
||
230 | */ |
||
231 | public function getFormat() |
||
235 | 1 | ||
236 | /** |
||
237 | * @param string $format |
||
238 | */ |
||
239 | public function setFormat($format) |
||
243 | |||
244 | /** |
||
245 | * @return \DateTime |
||
246 | */ |
||
247 | public function getCreatedAt() |
||
251 | 1 | ||
252 | /** |
||
253 | * @param \DateTime $createdAt |
||
254 | */ |
||
255 | public function setCreatedAt($createdAt) |
||
259 | 1 | ||
260 | /** |
||
261 | 1 | * @return \DateTime |
|
262 | 1 | */ |
|
263 | 1 | public function getUpdatedAt() |
|
267 | |||
268 | /** |
||
269 | * @param string $locale |
||
270 | * |
||
271 | * @return bool |
||
272 | */ |
||
273 | public function hasMessage($locale) |
||
274 | { |
||
282 | |||
283 | /** |
||
284 | 1 | * @param \DateTime $updatedAt |
|
285 | */ |
||
286 | public function setUpdatedAt($updatedAt) |
||
290 | |||
291 | /** |
||
292 | 1 | * {@inheritdoc} |
|
293 | */ |
||
294 | 1 | public function jsonSerialize() |
|
307 | |||
308 | /** |
||
309 | * Returns messages as array. |
||
310 | * |
||
311 | * Format: ['locale' => 'message']. |
||
312 | * |
||
313 | * @return array |
||
314 | */ |
||
315 | private function getMessagesArray() |
||
324 | |||
325 | /** |
||
326 | * Returns tags array. |
||
327 | * |
||
328 | * @return array |
||
329 | */ |
||
330 | private function getTagsArray() |
||
343 | } |
||
344 |
Our type inference engine has found an assignment to a property that is incompatible with the declared type of that property.
Either this assignment is in error or the assigned type should be added to the documentation/type hint for that property..