Completed
Pull Request — master (#139)
by
unknown
04:18
created

ModelParent::getArticlesCount()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 1

Importance

Changes 1
Bugs 0 Features 1
Metric Value
c 1
b 0
f 1
dl 0
loc 4
ccs 2
cts 2
cp 1
rs 10
cc 1
eloc 2
nc 1
nop 0
crap 1
1
<?php
2
3
namespace Yandex\Market\Content\Models;
4
5
use Yandex\Market\Content\Models\Base\MarketModel;
6
7
class ModelParent 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 $children = null;
46
47
    /**
48
     * Additional properties available during listed requests.
49
     */
50
    protected $childrenCount = null;
51
52
    protected $mappingClasses = [
53
        'photos' => 'Yandex\Market\Content\Models\Photos',
54
        'prices' => 'Yandex\Market\Content\Models\Prices',
55
        'facts' => 'Yandex\Market\Content\Models\Facts',
56
        'mainPhoto' => 'Yandex\Market\Content\Models\Base\Photo',
57
        'children' => 'Yandex\Market\Content\Models\Children'
58
    ];
59
60
    protected $propNameMap = [
61
        'vendor' => 'vendorName',
62
        'modificationsCount' => 'childrenCount',
63
        'gradeCount' => 'gradesCount'
64
    ];
65
66
    /**
67
     * Constructor
68
     *
69
     * @param array $data
70
     */
71 2
    public function __construct($data = array())
72
    {
73
        // fix photo inheritance
74
        // @todo: Check whether only one child can be inherit in "photos" property.
75 2
        if (isset($data['photos']) && count($data['photos']) == 1 && isset($data['photos']['photo'])
76 2
        ) {
77 1
            $data['photos'] = $data['photos']['photo'];
78 1
        }
79 2
        parent::__construct($data);
80 2
    }
81
    /**
82
     * Retrieve the offersCount property
83
     *
84
     * @return int|null
85
     */
86 2
    public function getOffersCount()
87
    {
88 2
        return $this->offersCount;
89
    }
90
91
    /**
92
     * Retrieve the rating property
93
     *
94
     * @return float|null
95
     */
96 1
    public function getRating()
97
    {
98 1
        return $this->rating;
99
    }
100
101
    /**
102
     * Retrieve the reviewsCount property
103
     *
104
     * @return int|null
105
     */
106 1
    public function getReviewsCount()
107
    {
108 1
        return $this->reviewsCount;
109
    }
110
111
    /**
112
     * Retrieve the articlesCount property
113
     *
114
     * @return int|null
115
     */
116 1
    public function getArticlesCount()
117
    {
118 1
        return $this->articlesCount;
119
    }
120
121
    /**
122
     * Retrieve the isNew property
123
     *
124
     * @return bool|null
125
     */
126 1
    public function getIsNew()
127
    {
128 1
        if ($this->isNew === null) {
129
            return null;
130
        }
131
132 1
        if ($this->isNew == 1) {
133
            return true;
134
        }
135
136 1
        return false;
137
    }
138
139
    /**
140
     * Retrieve the vendorId property
141
     *
142
     * @return int|null
143
     */
144 1
    public function getVendorId()
145
    {
146 1
        return $this->vendorId;
147
    }
148
149
    /**
150
     * Retrieve the gradesCount property
151
     *
152
     * @return int|null
153
     */
154 1
    public function getGradesCount()
155
    {
156 1
        return $this->gradesCount;
157
    }
158
159
    /**
160
     * Retrieve the categoryId property
161
     *
162
     * @return int|null
163
     */
164 2
    public function getCategoryId()
165
    {
166 2
        return $this->categoryId;
167
    }
168
169
    /**
170
     * Retrieve the id property
171
     *
172
     * @return int|null
173
     */
174 2
    public function getId()
175
    {
176 2
        return $this->id;
177
    }
178
179
    /**
180
     * Retrieve the id property
181
     *
182
     * @return Photos|null
183
     */
184 1
    public function getPhotos()
185
    {
186 1
        return $this->photos;
187
    }
188
189
    /**
190
     * Retrieve the link property
191
     *
192
     * @return string|null
193
     */
194 1
    public function getLink()
195
    {
196 1
        return $this->link;
197
    }
198
199
    /**
200
     * Retrieve the isGroup property
201
     *
202
     * @return bool|null
203
     */
204 1
    public function getIsGroup()
205
    {
206 1
        return $this->isGroup;
207
    }
208
209
    /**
210
     * Retrieve the vendorName property
211
     * @return string|null
212
     */
213 1
    public function getVendorName()
214
    {
215 1
        return $this->vendorName;
216
    }
217
218
    /**
219
     * Retrieve the name property
220
     * @return string|null
221
     */
222 2
    public function getName()
223
    {
224 2
        return $this->name;
225
    }
226
227
    /**
228
     * Retrieve the prices property
229
     *
230
     * @return Prices|null
231
     */
232 2
    public function getPrices()
233
    {
234 2
        return $this->prices;
235
    }
236
237
    /**
238
     * Retrieve the description property
239
     * @return string|null
240
     */
241 2
    public function getDescription()
242
    {
243 2
        return $this->description;
244
    }
245
246
    /**
247
     * Retrieve the facts property
248
     *
249
     * @return Facts|null
250
     */
251
    public function getFacts()
252
    {
253
        return $this->facts;
254
    }
255
256
    /**
257
     * Retrieve the mainPhoto property
258
     *
259
     * @return Photo|null
260
     */
261 1
    public function getMainPhoto()
262
    {
263 1
        return $this->mainPhoto;
264
    }
265
266
    /**
267
     * Retrieve the children property
268
     *
269
     * @return Children|null
270
     */
271 1
    public function getChildren()
272
    {
273 1
        return $this->children;
274
    }
275
276
    /**
277
     * Retrieve the childrenCount property
278
     *
279
     * @note Property available during /category/{category_id}/models request.
280
     *
281
     * @return int|null
282
     */
283
    public function getChildrenCount()
284
    {
285
        return $this->childrenCount;
286
    }
287
}
288