Test Failed
Branch master (16bdc1)
by SignpostMarv
02:18
created

Product::GetWeight()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 8
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 3
CRAP Score 1

Importance

Changes 0
Metric Value
cc 1
eloc 2
nc 1
nop 0
dl 0
loc 8
ccs 3
cts 3
cp 1
crap 1
rs 10
c 0
b 0
f 0
1
<?php
2
/**
3
* @author SignpostMarv
4
*/
5
declare(strict_types=1);
6
7
namespace SignpostMarv\DaftObject\SchemaOrg;
8
9
use SignpostMarv\DaftObject\SchemaOrg\CreativeWork\MediaObject\ImageObject;
10
use SignpostMarv\DaftObject\SchemaOrg\CreativeWork\Review;
11
use SignpostMarv\DaftObject\SchemaOrg\Intangible\Brand;
12
use SignpostMarv\DaftObject\SchemaOrg\Intangible\Enumeration\OfferItemCondition;
13
use SignpostMarv\DaftObject\SchemaOrg\Intangible\Enumeration\PhysicalActivityCategory;
14
use SignpostMarv\DaftObject\SchemaOrg\Intangible\Quantity\Distance;
15
use SignpostMarv\DaftObject\SchemaOrg\Intangible\Rating\AggregateRating;
16
use SignpostMarv\DaftObject\SchemaOrg\Intangible\Service;
17
use SignpostMarv\DaftObject\SchemaOrg\Intangible\StructuredValue\PropertyValue;
18
use SignpostMarv\DaftObject\SchemaOrg\Intangible\StructuredValue\QuantitativeValue;
19
20
/**
21
* @property array<int, PropertyValue> $additionalProperty
22
* @property array<int, AggregateRating> $aggregateRating
23
* @property array<int, Audience> $audience
24
* @property array<int, string> $award
25
* @property array<int, Brand|Organization> $brand
26
* @property array<int, string|Thing|PhysicalActivityCategory> $category
27
* @property array<int, string> $color
28
* @property array<int, Distance|QuantitativeValue> $depth
29
* @property array<int, string> $gtin12
30
* @property array<int, string> $gtin13
31
* @property array<int, string> $gtin14
32
* @property array<int, string> $gtin8
33
* @property array<int, Distance|QuantitativeValue> $height
34
* @property array<int, Product> $isAccessoryOrSparePartFor
35
* @property array<int, Product> $isConsumableFor
36
* @property array<int, Product|Service> $isRelatedTo
37
* @property array<int, Product|Service> $isSimilarTo
38
* @property array<int, OfferItemCondition> $itemCondition
39
* @property array<int, ImageObject> $logo
40
* @property array<int, Organization> $manufacturer
41
* @property array<int, string|Product> $material
42
* @property array<int, string|Product\ProductModel> $model
43
* @property array<int, string> $mpn
44
* @property array<int, Offer> $offers
45
* @property array<int, string> $productID
46
* @property array<int, DataTypes\Date> $productionDate
47
* @property array<int, DataTypes\Date> $purchaseDate
48
* @property array<int, DataTypes\Date> $releaseDate
49
* @property array<int, Review> $review
50
* @property array<int, string> $sku
51
* @property array<int, QuantitativeValue> $weight
52
* @property array<int, Distance|QuantitativeValue> $width
53
*/
54
class Product extends Thing
55
{
56
    use DaftObjectTraits\TraitAdditionalProperty;
57
    use DaftObjectTraits\HasAggregateRating;
58
    use DaftObjectTraits\HasAudience;
59
    use DaftObjectTraits\HasAward;
60
    use DaftObjectTraits\HasBrand;
61
    use DaftObjectTraits\HasCategory;
62
    use DaftObjectTraits\HasGtin;
63
    use DaftObjectTraits\HasHeights;
64
    use DaftObjectTraits\HasItemCondition;
65
    use DaftObjectTraits\HasLogo;
66
    use DaftObjectTraits\IsRelatedOrSimilarTo;
67
    use DaftObjectTraits\HasMaterial;
68
    use DaftObjectTraits\HasMpn;
69
    use DaftObjectTraits\HasOffers;
70
    use DaftObjectTraits\HasReview;
71
    use DaftObjectTraits\HasSku;
72
    use DaftObjectTraits\Weight;
73
    use DaftObjectTraits\HasWidth;
74
75
    const SCHEMA_ORG_TYPE = 'Product';
76
77
    const PROPERTIES = [
78
        'additionalProperty',
79
        'aggregateRating',
80
        'audience',
81
        'award',
82
        'brand',
83
        'category',
84
        'color',
85
        'depth',
86
        'gtin12',
87
        'gtin13',
88
        'gtin14',
89
        'gtin8',
90
        'height',
91
        'isAccessoryOrSparePartFor',
92
        'isConsumableFor',
93
        'isRelatedTo',
94
        'isSimilarTo',
95
        'itemCondition',
96
        'logo',
97
        'manufacturer',
98
        'material',
99
        'model',
100
        'mpn',
101
        'offers',
102
        'productID',
103
        'productionDate',
104
        'purchaseDate',
105
        'releaseDate',
106
        'review',
107
        'sku',
108
        'weight',
109
        'width',
110
    ];
111
112
    const PROPERTIES_WITH_MULTI_TYPED_ARRAYS = [
113
        'additionalProperty' => [
114
            PropertyValue::class,
115
        ],
116
        'aggregateRating' => [
117
            AggregateRating::class,
118
        ],
119
        'audience' => [
120
            Audience::class,
121
        ],
122
        'award' => [
123
            'string',
124
        ],
125
        'brand' => [
126
            Brand::class,
127
            Organization::class,
128
        ],
129
        'category' => [
130
            'string',
131
            Thing::class,
132
            PhysicalActivityCategory::class,
133
        ],
134
        'color' => [
135
            'string',
136
        ],
137
        'depth' => [
138
            Distance::class,
139
            QuantitativeValue::class,
140
        ],
141
        'gtin12' => [
142
            'string',
143
        ],
144
        'gtin13' => [
145
            'string',
146
        ],
147
        'gtin14' => [
148
            'string',
149
        ],
150
        'gtin8' => [
151
            'string',
152
        ],
153
        'height' => [
154
            Distance::class,
155
            QuantitativeValue::class,
156
        ],
157
        'isAccessoryOrSparePartFor' => [
158
            Product::class,
159
        ],
160
        'isConsumableFor' => [
161
            Product::class,
162
        ],
163
        'isRelatedTo' => [
164
            Product::class,
165
            Service::class,
166
        ],
167
        'isSimilarTo' => [
168
            Product::class,
169
            Service::class,
170
        ],
171
        'itemCondition' => [
172
            OfferItemCondition::class,
173
        ],
174
        'logo' => [
175
            ImageObject::class,
176
        ],
177
        'manufacturer' => [
178
            Organization::class,
179
        ],
180
        'material' => [
181
            'string',
182
            Product::class,
183
        ],
184
        'model' => [
185
            'string',
186
            Product\ProductModel::class,
187
        ],
188
        'mpn' => [
189
            'string',
190
        ],
191
        'offers' => [
192
            Offer::class,
193
        ],
194
        'productID' => [
195
            'string',
196
        ],
197
        'productionDate' => [
198
            DataTypes\Date::class,
199
        ],
200
        'purchaseDate' => [
201
            DataTypes\Date::class,
202
        ],
203
        'releaseDate' => [
204
            DataTypes\Date::class,
205
        ],
206
        'review' => [
207
            Review::class,
208
        ],
209
        'sku' => [
210
            'string',
211
        ],
212
        'weight' => [
213
            QuantitativeValue::class,
214
        ],
215
        'width' => [
216
            Distance::class,
217
            QuantitativeValue::class,
218
        ],
219
    ];
220
221
    /**
222
    * @return array<int, string>
223 89
    */
224
    public function GetColor() : array
225
    {
226
        /**
227
        * @var array<int, string>
228 89
        */
229
        $out = $this->ExpectRetrievedValueIsArray('color');
230 89
231
        return $out;
232
    }
233
234
    /**
235
    * @param array<int, string> $value
236 3
    */
237
    public function SetColor(array $value) : void
238 3
    {
239 3
        $this->NudgePropertyValue('color', $value, true);
240
    }
241
242
    /**
243
    * @return array<int, Distance|QuantitativeValue>
244 89
    */
245
    public function GetDepth() : array
246
    {
247
        /**
248
        * @var array<int, Distance|QuantitativeValue>
249 89
        */
250
        $out = $this->ExpectRetrievedValueIsArray('depth');
251 89
252
        return $out;
253
    }
254
255
    /**
256
    * @param array<int, Distance|QuantitativeValue> $value
257 3
    */
258
    public function SetDepth(array $value) : void
259 3
    {
260 3
        $this->NudgePropertyValue('depth', $value);
261
    }
262
263
    /**
264
    * @return array<int, Product>
265 89
    */
266
    public function GetIsAccessoryOrSparePartFor() : array
267
    {
268
        /**
269
        * @var array<int, Product>
270 89
        */
271
        $out = $this->ExpectRetrievedValueIsArray('isAccessoryOrSparePartFor');
272 89
273
        return $out;
274
    }
275
276
    /**
277
    * @param array<int, Product> $value
278 3
    */
279
    public function SetIsAccessoryOrSparePartFor(array $value) : void
280 3
    {
281 3
        $this->NudgePropertyValue('isAccessoryOrSparePartFor', $value);
282
    }
283
284
    /**
285
    * @return array<int, Product>
286 89
    */
287
    public function GetIsConsumableFor() : array
288
    {
289
        /**
290
        * @var array<int, Product>
291 89
        */
292
        $out = $this->ExpectRetrievedValueIsArray('isConsumableFor');
293 89
294
        return $out;
295
    }
296
297
    /**
298
    * @param array<int, Product> $value
299 3
    */
300
    public function SetIsConsumableFor(array $value) : void
301 3
    {
302 3
        $this->NudgePropertyValue('isConsumableFor', $value);
303
    }
304
305
    /**
306
    * @return array<int, Organization>
307 89
    */
308
    public function GetManufacturer() : array
309
    {
310
        /**
311
        * @var array<int, Organization>
312 89
        */
313
        $out = $this->ExpectRetrievedValueIsArray('manufacturer');
314 89
315
        return $out;
316
    }
317
318
    /**
319
    * @param array<int, Organization> $value
320 3
    */
321
    public function SetManufacturer(array $value) : void
322 3
    {
323 3
        $this->NudgePropertyValue('manufacturer', $value);
324
    }
325
326
    /**
327
    * @return array<int, string|Product\ProductModel>
328 89
    */
329
    public function GetModel() : array
330
    {
331
        /**
332
        * @var array<int, string|Product\ProductModel>
333 89
        */
334
        $out = $this->ExpectRetrievedValueIsArray('model');
335 89
336
        return $out;
337
    }
338
339
    /**
340
    * @param array<int, string|Product\ProductModel> $value
341 3
    */
342
    public function SetModel(array $value) : void
343 3
    {
344 3
        $this->NudgePropertyValue('model', $value, true);
345
    }
346
347
    /**
348
    * @return array<int, string>
349 89
    */
350
    public function GetProductID() : array
351
    {
352
        /**
353
        * @var array<int, string>
354 89
        */
355
        $out = $this->ExpectRetrievedValueIsArray('productID');
356 89
357
        return $out;
358
    }
359
360
    /**
361
    * @param array<int, string> $value
362 3
    */
363
    public function SetProductID(array $value) : void
364 3
    {
365 3
        $this->NudgePropertyValue('productID', $value, true);
366
    }
367
368
    /**
369
    * @return array<int, DataTypes\Date>
370 89
    */
371
    public function GetProductionDate() : array
372
    {
373
        /**
374
        * @var array<int, DataTypes\Date>
375 89
        */
376
        $out = $this->ExpectRetrievedValueIsArray('productionDate');
377 89
378
        return $out;
379
    }
380
381
    /**
382
    * @param array<int, DataTypes\Date> $value
383 3
    */
384
    public function SetProductionDate(array $value) : void
385 3
    {
386 3
        $this->NudgePropertyValue('productionDate', $value);
387
    }
388
389
    /**
390
    * @return array<int, DataTypes\Date>
391 89
    */
392
    public function GetPurchaseDate() : array
393
    {
394
        /**
395
        * @var array<int, DataTypes\Date>
396 89
        */
397
        $out = $this->ExpectRetrievedValueIsArray('purchaseDate');
398 89
399
        return $out;
400
    }
401
402
    /**
403
    * @param array<int, DataTypes\Date> $value
404 3
    */
405
    public function SetPurchaseDate(array $value) : void
406 3
    {
407 3
        $this->NudgePropertyValue('purchaseDate', $value);
408
    }
409
410
    /**
411
    * @return array<int, DataTypes\Date>
412 89
    */
413
    public function GetReleaseDate() : array
414
    {
415
        /**
416
        * @var array<int, DataTypes\Date>
417 89
        */
418
        $out = $this->ExpectRetrievedValueIsArray('releaseDate');
419 89
420
        return $out;
421
    }
422
423
    /**
424
    * @param array<int, DataTypes\Date> $value
425 3
    */
426
    public function SetReleaseDate(array $value) : void
427 3
    {
428 3
        $this->NudgePropertyValue('releaseDate', $value);
429
    }
430
}
431