1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace Yandex\Market\Content\Models; |
4
|
|
|
|
5
|
|
|
use Yandex\Market\Content\Models\Base\MarketModel; |
6
|
|
|
|
7
|
|
View Code Duplication |
class ModelChild extends MarketModel |
|
|
|
|
8
|
|
|
{ |
9
|
|
|
protected $offersCount = null; |
10
|
|
|
|
11
|
|
|
protected $rating = null; |
12
|
|
|
|
13
|
|
|
protected $reviewsCount = null; |
14
|
|
|
|
15
|
|
|
protected $articlesCount = null; |
16
|
|
|
|
17
|
|
|
protected $isNew = null; |
18
|
|
|
|
19
|
|
|
protected $vendorId = null; |
20
|
|
|
|
21
|
|
|
protected $gradesCount = null; |
22
|
|
|
|
23
|
|
|
protected $categoryId = null; |
24
|
|
|
|
25
|
|
|
protected $id = null; |
26
|
|
|
|
27
|
|
|
protected $photos = null; |
28
|
|
|
|
29
|
|
|
protected $link = null; |
30
|
|
|
|
31
|
|
|
protected $isGroup = null; |
32
|
|
|
|
33
|
|
|
protected $vendorName = null; |
34
|
|
|
|
35
|
|
|
protected $name = null; |
36
|
|
|
|
37
|
|
|
protected $prices = null; |
38
|
|
|
|
39
|
|
|
protected $description = null; |
40
|
|
|
|
41
|
|
|
protected $facts = null; |
42
|
|
|
|
43
|
|
|
protected $mainPhoto = null; |
44
|
|
|
|
45
|
|
|
protected $parent = null; |
46
|
|
|
|
47
|
|
|
/** |
48
|
|
|
* Additional properties available during listed requests. |
49
|
|
|
*/ |
50
|
|
|
protected $childrenCount = null; |
51
|
|
|
|
52
|
|
|
protected $popularity = null; |
53
|
|
|
|
54
|
|
|
protected $mappingClasses = [ |
55
|
|
|
'photos' => 'Yandex\Market\Content\Models\Photos', |
56
|
|
|
'prices' => 'Yandex\Market\Content\Models\Prices', |
57
|
|
|
'facts' => 'Yandex\Market\Content\Models\Facts', |
58
|
|
|
'mainPhoto' => 'Yandex\Market\Content\Models\Base\Photo', |
59
|
|
|
'parent' => 'Yandex\Market\Content\Models\ModelParent' |
60
|
|
|
]; |
61
|
|
|
|
62
|
|
|
protected $propNameMap = [ |
63
|
|
|
'vendor' => 'vendorName', |
64
|
|
|
'parentModel' => 'parent', |
65
|
|
|
'modificationsCount' => 'childrenCount', |
66
|
|
|
'gradeCount' => 'gradesCount' |
67
|
|
|
]; |
68
|
|
|
|
69
|
|
|
/** |
70
|
|
|
* Constructor |
71
|
|
|
* |
72
|
|
|
* @param array $data |
73
|
|
|
*/ |
74
|
1 |
|
public function __construct($data = array()) |
75
|
|
|
{ |
76
|
|
|
// fix photo inheritance |
77
|
|
|
// @todo: Check whether only one child can be inherit in "photos" property. |
78
|
1 |
|
if (isset($data['photos']) && count($data['photos']) == 1 && isset($data['photos']['photo']) |
79
|
1 |
|
) { |
80
|
1 |
|
$data['photos'] = $data['photos']['photo']; |
81
|
1 |
|
} |
82
|
1 |
|
parent::__construct($data); |
83
|
1 |
|
} |
84
|
|
|
|
85
|
|
|
/** |
86
|
|
|
* Retrieve the offersCount property |
87
|
|
|
* |
88
|
|
|
* @return int|null |
89
|
|
|
*/ |
90
|
1 |
|
public function getOffersCount() |
91
|
|
|
{ |
92
|
1 |
|
return $this->offersCount; |
93
|
|
|
} |
94
|
|
|
|
95
|
|
|
/** |
96
|
|
|
* Retrieve the rating property |
97
|
|
|
* |
98
|
|
|
* @return float|null |
99
|
|
|
*/ |
100
|
1 |
|
public function getRating() |
101
|
|
|
{ |
102
|
1 |
|
return $this->rating; |
103
|
|
|
} |
104
|
|
|
|
105
|
|
|
/** |
106
|
|
|
* Retrieve the reviewsCount property |
107
|
|
|
* |
108
|
|
|
* @return int|null |
109
|
|
|
*/ |
110
|
1 |
|
public function getReviewsCount() |
111
|
|
|
{ |
112
|
1 |
|
return $this->reviewsCount; |
113
|
|
|
} |
114
|
|
|
|
115
|
|
|
/** |
116
|
|
|
* Retrieve the articlesCount property |
117
|
|
|
* |
118
|
|
|
* @return int|null |
119
|
|
|
*/ |
120
|
1 |
|
public function getArticlesCount() |
121
|
|
|
{ |
122
|
1 |
|
return $this->articlesCount; |
123
|
|
|
} |
124
|
|
|
|
125
|
|
|
/** |
126
|
|
|
* Retrieve the isNew property |
127
|
|
|
* |
128
|
|
|
* @return bool|null |
129
|
|
|
*/ |
130
|
1 |
|
public function getIsNew() |
131
|
|
|
{ |
132
|
1 |
|
if ($this->isNew === null) { |
133
|
|
|
return null; |
134
|
|
|
} |
135
|
|
|
|
136
|
1 |
|
if ($this->isNew == 1) { |
137
|
|
|
return true; |
138
|
|
|
} |
139
|
|
|
|
140
|
1 |
|
return false; |
141
|
|
|
} |
142
|
|
|
|
143
|
|
|
/** |
144
|
|
|
* Retrieve the vendorId property |
145
|
|
|
* |
146
|
|
|
* @return int|null |
147
|
|
|
*/ |
148
|
1 |
|
public function getVendorId() |
149
|
|
|
{ |
150
|
1 |
|
return $this->vendorId; |
151
|
|
|
} |
152
|
|
|
|
153
|
|
|
/** |
154
|
|
|
* Retrieve the gradesCount property |
155
|
|
|
* |
156
|
|
|
* @return int|null |
157
|
|
|
*/ |
158
|
1 |
|
public function getGradesCount() |
159
|
|
|
{ |
160
|
1 |
|
return $this->gradesCount; |
161
|
|
|
} |
162
|
|
|
|
163
|
|
|
/** |
164
|
|
|
* Retrieve the categoryId property |
165
|
|
|
* |
166
|
|
|
* @return int|null |
167
|
|
|
*/ |
168
|
1 |
|
public function getCategoryId() |
169
|
|
|
{ |
170
|
1 |
|
return $this->categoryId; |
171
|
|
|
} |
172
|
|
|
|
173
|
|
|
/** |
174
|
|
|
* Retrieve the id property |
175
|
|
|
* |
176
|
|
|
* @return int|null |
177
|
|
|
*/ |
178
|
1 |
|
public function getId() |
179
|
|
|
{ |
180
|
1 |
|
return $this->id; |
181
|
|
|
} |
182
|
|
|
|
183
|
|
|
/** |
184
|
|
|
* Retrieve the id property |
185
|
|
|
* |
186
|
|
|
* @return Photos|null |
187
|
|
|
*/ |
188
|
1 |
|
public function getPhotos() |
189
|
|
|
{ |
190
|
1 |
|
return $this->photos; |
191
|
|
|
} |
192
|
|
|
|
193
|
|
|
/** |
194
|
|
|
* Retrieve the link property |
195
|
|
|
* |
196
|
|
|
* @return string|null |
197
|
|
|
*/ |
198
|
1 |
|
public function getLink() |
199
|
|
|
{ |
200
|
1 |
|
return $this->link; |
201
|
|
|
} |
202
|
|
|
|
203
|
|
|
/** |
204
|
|
|
* Retrieve the isGroup property |
205
|
|
|
* |
206
|
|
|
* @return bool|null |
207
|
|
|
*/ |
208
|
1 |
|
public function getIsGroup() |
209
|
|
|
{ |
210
|
1 |
|
return $this->isGroup; |
211
|
|
|
} |
212
|
|
|
|
213
|
|
|
/** |
214
|
|
|
* Retrieve the vendorName property |
215
|
|
|
* @return string|null |
216
|
|
|
*/ |
217
|
1 |
|
public function getVendorName() |
218
|
|
|
{ |
219
|
1 |
|
return $this->vendorName; |
220
|
|
|
} |
221
|
|
|
|
222
|
|
|
/** |
223
|
|
|
* Retrieve the name property |
224
|
|
|
* @return string|null |
225
|
|
|
*/ |
226
|
1 |
|
public function getName() |
227
|
|
|
{ |
228
|
1 |
|
return $this->name; |
229
|
|
|
} |
230
|
|
|
|
231
|
|
|
/** |
232
|
|
|
* Retrieve the prices property |
233
|
|
|
* |
234
|
|
|
* @return Prices|null |
235
|
|
|
*/ |
236
|
1 |
|
public function getPrices() |
237
|
|
|
{ |
238
|
1 |
|
return $this->prices; |
239
|
|
|
} |
240
|
|
|
|
241
|
|
|
/** |
242
|
|
|
* Retrieve the description property |
243
|
|
|
* @return string|null |
244
|
|
|
*/ |
245
|
1 |
|
public function getDescription() |
246
|
|
|
{ |
247
|
1 |
|
return $this->description; |
248
|
|
|
} |
249
|
|
|
|
250
|
|
|
/** |
251
|
|
|
* Retrieve the facts property |
252
|
|
|
* |
253
|
|
|
* @return Facts|null |
254
|
|
|
*/ |
255
|
|
|
public function getFacts() |
256
|
|
|
{ |
257
|
|
|
return $this->facts; |
258
|
|
|
} |
259
|
|
|
|
260
|
|
|
/** |
261
|
|
|
* Retrieve the mainPhoto property |
262
|
|
|
* |
263
|
|
|
* @return Photo|null |
264
|
|
|
*/ |
265
|
1 |
|
public function getMainPhoto() |
266
|
|
|
{ |
267
|
1 |
|
return $this->mainPhoto; |
268
|
|
|
} |
269
|
|
|
|
270
|
|
|
/** |
271
|
|
|
* Retrieve the parent property |
272
|
|
|
* |
273
|
|
|
* @return ModelParent|null |
274
|
|
|
*/ |
275
|
1 |
|
public function getParent() |
276
|
|
|
{ |
277
|
1 |
|
return $this->parent; |
278
|
|
|
} |
279
|
|
|
|
280
|
|
|
/** |
281
|
|
|
* Retrieve the childrenCount property |
282
|
|
|
* |
283
|
|
|
* @note Property available during /category/{category_id}/models request. |
284
|
|
|
* |
285
|
|
|
* @return int|null |
286
|
|
|
*/ |
287
|
|
|
public function getChildrenCount() |
288
|
|
|
{ |
289
|
|
|
return $this->childrenCount; |
290
|
|
|
} |
291
|
|
|
|
292
|
|
|
/** |
293
|
|
|
* Retrieve the popularity property |
294
|
|
|
* |
295
|
|
|
* @note Property available during /model/{model_id} request. |
296
|
|
|
* for list of children models in parent model. |
297
|
|
|
* |
298
|
|
|
* @return float|null |
299
|
|
|
*/ |
300
|
1 |
|
public function getPopularity() |
301
|
|
|
{ |
302
|
1 |
|
return $this->popularity; |
303
|
|
|
} |
304
|
|
|
} |
305
|
|
|
|
Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.
You can also find more detailed suggestions in the “Code” section of your repository.