Passed
Push — master ( 81601f...461a97 )
by SignpostMarv
12:06
created

Offer   A

Complexity

Total Complexity 10

Size/Duplication

Total Lines 262
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
eloc 140
dl 0
loc 262
ccs 61
cts 61
cp 1
rs 10
c 0
b 0
f 0
wmc 10

10 Methods

Rating   Name   Duplication   Size   Complexity  
A SetPriceValidUntil() 0 7 1
A GetAddOn() 0 12 1
A SetOfferedBy() 0 6 1
A SetPrice() 0 6 1
A GetOfferedBy() 0 12 1
A GetPriceCurrency() 0 12 1
A SetPriceCurrency() 0 6 1
A SetAddOn() 0 7 1
A GetPrice() 0 12 1
A GetPriceValidUntil() 0 12 1
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\Review;
10
use SignpostMarv\DaftObject\SchemaOrg\DataTypes\Date;
11
use SignpostMarv\DaftObject\SchemaOrg\Intangible\Enumeration\DeliveryMethod;
12
use SignpostMarv\DaftObject\SchemaOrg\Intangible\Enumeration\OfferItemCondition;
13
use SignpostMarv\DaftObject\SchemaOrg\Intangible\Enumeration\PhysicalActivityCategory;
14
use SignpostMarv\DaftObject\SchemaOrg\Intangible\Rating\AggregateRating;
15
use SignpostMarv\DaftObject\SchemaOrg\Intangible\Service;
16
use SignpostMarv\DaftObject\SchemaOrg\Intangible\StructuredValue\QuantitativeValue;
17
use SignpostMarv\DaftObject\SchemaOrg\Intangible\StructuredValue\WarrantyPromise;
18
19
/**
20
* @property array<int, Offer> $addOn
21
* @property array<int, AggregateRating> $aggregateRating
22
* @property array<int, Place> $availableAtOrFrom
23
* @property array<int, DeliveryMethod> $availableDeliveryMethod
24
* @property array<int, string|Thing|PhysicalActivityCategory> $category
25
* @property array<int, QuantitativeValue> $inventoryLevel
26
* @property array<int, OfferItemCondition> $itemCondition
27
* @property array<int, Product|Service> $itemOffered
28
* @property array<int, string> $mpn
29
* @property array<int, Organization|Person> $offeredBy
30
* @property array<int, string|float|int> $price
31
* @property array<int, string> $priceCurrency
32
* @property array<int, PriceSpecification> $priceSpecification
33
* @property array<int, Date> $priceValidUntil
34
* @property array<int, Review> $review
35
* @property array<int, Organization|Person> $seller
36
* @property array<int, string> $serialNumber
37
* @property array<int, WarrantyPromise> $warranty
38
*/
39
class Offer extends Thing
40
{
41
    use DaftObjectTraits\IsOfferOrDemand;
42
    use DaftObjectTraits\HasAggregateRating;
43
    use DaftObjectTraits\HasCategory;
44
    use DaftObjectTraits\HasItemCondition;
45
    use DaftObjectTraits\HasMpn;
46
    use DaftObjectTraits\HasReview;
47
48
    const SCHEMA_ORG_TYPE = 'Offer';
49
50
    const PROPERTIES = [
51
        'acceptedPaymentMethod',
52
        'addOn',
53
        'advanceBookingRequirement',
54
        'aggregateRating',
55
        'areaServed',
56
        'availability',
57
        'availabilityEnds',
58
        'availabilityStarts',
59
        'availableAtOrFrom',
60
        'availableDeliveryMethod',
61
        'businessFunction',
62
        'category',
63
        'deliveryLeadTime',
64
        'eligibleCustomerType',
65
        'eligibleDuration',
66
        'eligibleQuantity',
67
        'eligibleRegion',
68
        'eligibleTransactionVolume',
69
        'gtin12',
70
        'gtin13',
71
        'gtin14',
72
        'gtin8',
73
        'includesObject',
74
        'ineligibleRegion',
75
        'inventoryLevel',
76
        'itemCondition',
77
        'itemOffered',
78
        'mpn',
79
        'offeredBy',
80
        'price',
81
        'priceCurrency',
82
        'priceSpecification',
83
        'priceValidUntil',
84
        'review',
85
        'seller',
86
        'serialNumber',
87
        'sku',
88
        'validFrom',
89
        'validThrough',
90
        'warranty',
91
    ];
92
93
    const PROPERTIES_WITH_MULTI_TYPED_ARRAYS = [
94
        'addOn' => [
95
            Offer::class,
96
        ],
97
        'aggregateRating' => [
98
            AggregateRating::class,
99
        ],
100
        'availableAtOrFrom' => [
101
            Place::class,
102
        ],
103
        'availableDeliveryMethod' => [
104
            DeliveryMethod::class,
105
        ],
106
        'category' => [
107
            'string',
108
            Thing::class,
109
            PhysicalActivityCategory::class,
110
        ],
111
        'inventoryLevel' => [
112
            QuantitativeValue::class,
113
        ],
114
        'itemCondition' => [
115
            OfferItemCondition::class,
116
        ],
117
        'itemOffered' => [
118
            Product::class,
119
            Service::class,
120
        ],
121
        'mpn' => [
122
            'string',
123
        ],
124
        'offeredBy' => [
125
            Organization::class,
126
            Person::class,
127
        ],
128
        'price' => [
129
            'string',
130
            'double',
131
            'integer',
132
        ],
133
        'priceCurrency' => [
134
            'string',
135
        ],
136
        'priceSpecification' => [
137
            PriceSpecification::class,
138
        ],
139
        'priceValidUntil' => [
140
            Date::class,
141
        ],
142
        'review' => [
143
            Review::class,
144
        ],
145
        'seller' => [
146
            Organization::class,
147
            Person::class,
148
        ],
149
        'serialNumber' => [
150
            'string',
151
        ],
152
        'warranty' => [
153
            WarrantyPromise::class,
154
        ],
155
    ];
156
157
    /**
158
    * @return array<int, Offer>
159
    */
160 84
    public function GetAddOn() : array
161
    {
162
        /**
163
        * @var array<int, Offer>
164
        */
165 84
        $out = TypeUtilities::ExpectRetrievedValueIsArray(
166 84
            'addOn',
167 84
            $this->RetrievePropertyValueFromData('addOn'),
168 84
            static::class
169
        );
170
171 84
        return $out;
172
    }
173
174
    /**
175
    * @param array<int, Offer> $value
176
    */
177 1
    public function SetAddOn(array $value) : void
178
    {
179 1
        $this->NudgePropertyWithUniqueValuesOfThings(
180 1
            'addOn',
181 1
            __METHOD__,
182 1
            $value,
183 1
            Offer::class
184
        );
185 1
    }
186
187
    /**
188
    * @return array<int, Organization|Person>
189
    */
190 84
    public function GetOfferedBy() : array
191
    {
192
        /**
193
        * @var array<int, Organization|Person>
194
        */
195 84
        $out = TypeUtilities::ExpectRetrievedValueIsArray(
196 84
            'offeredBy',
197 84
            $this->RetrievePropertyValueFromData('offeredBy'),
198 84
            static::class
199
        );
200
201 84
        return $out;
202
    }
203
204
    /**
205
    * @param array<int, Organization|Person> $value
206
    */
207 1
    public function SetOfferedBy(array $value) : void
208
    {
209 1
        $this->NudgePropertyWithUniqueOrganizationsOrPersons(
210 1
            'offeredBy',
211 1
            __METHOD__,
212 1
            $value
213
        );
214 1
    }
215
216
    /**
217
    * @return array<int, string|float|int>
218
    */
219 84
    public function GetPrice() : array
220
    {
221
        /**
222
        * @var array<int, string|float|int>
223
        */
224 84
        $out = TypeUtilities::ExpectRetrievedValueIsArray(
225 84
            'price',
226 84
            $this->RetrievePropertyValueFromData('price'),
227 84
            static::class
228
        );
229
230 84
        return $out;
231
    }
232
233
    /**
234
    * @param array<int, string|float|int> $value
235
    */
236 1
    public function SetPrice(array $value) : void
237
    {
238 1
        $this->NudgePropertyWithUniqueTrimmedStringsNumericsMightNotBeStringsOrNumerics(
239 1
            'price',
240 1
            __METHOD__,
241 1
            $value
242
        );
243 1
    }
244
245
    /**
246
    * @return array<int, string>
247
    */
248 84
    public function GetPriceCurrency() : array
249
    {
250
        /**
251
        * @var array<int, string>
252
        */
253 84
        $out = TypeUtilities::ExpectRetrievedValueIsArray(
254 84
            'priceCurrency',
255 84
            $this->RetrievePropertyValueFromData('priceCurrency'),
256 84
            static::class
257
        );
258
259 84
        return $out;
260
    }
261
262
    /**
263
    * @param array<int, string> $value
264
    */
265 1
    public function SetPriceCurrency(array $value) : void
266
    {
267 1
        $this->NudgePropertyWithUniqueTrimmedStringsMightNotBeString(
268 1
            'priceCurrency',
269 1
            __METHOD__,
270 1
            $value
271
        );
272 1
    }
273
274
    /**
275
    * @return array<int, Date>
276
    */
277 84
    public function GetPriceValidUntil() : array
278
    {
279
        /**
280
        * @var array<int, Date>
281
        */
282 84
        $out = TypeUtilities::ExpectRetrievedValueIsArray(
283 84
            'priceValidUntil',
284 84
            $this->RetrievePropertyValueFromData('priceValidUntil'),
285 84
            static::class
286
        );
287
288 84
        return $out;
289
    }
290
291
    /**
292
    * @param array<int, Date> $value
293
    */
294 1
    public function SetPriceValidUntil(array $value) : void
295
    {
296 1
        $this->NudgePropertyWithUniqueValuesOfThings(
297 1
            'priceValidUntil',
298 1
            __METHOD__,
299 1
            $value,
300 1
            Date::class
301
        );
302 1
    }
303
}
304