|
1
|
|
|
<?php |
|
2
|
|
|
/** |
|
3
|
|
|
* @author SignpostMarv |
|
4
|
|
|
*/ |
|
5
|
|
|
declare(strict_types=1); |
|
6
|
|
|
|
|
7
|
|
|
namespace SignpostMarv\DaftObject\SchemaOrg\CreativeWork; |
|
8
|
|
|
|
|
9
|
|
|
use SignpostMarv\DaftObject\SchemaOrg\CreativeWork as Base; |
|
10
|
|
|
use SignpostMarv\DaftObject\SchemaOrg\DaftObjectTraits; |
|
11
|
|
|
use SignpostMarv\DaftObject\SchemaOrg\Intangible\Rating; |
|
12
|
|
|
use SignpostMarv\DaftObject\SchemaOrg\Thing; |
|
13
|
|
|
use SignpostMarv\DaftObject\SchemaOrg\TypeUtilities; |
|
14
|
|
|
|
|
15
|
|
|
/** |
|
16
|
|
|
* @property array<int, Thing> $itemReviewed |
|
17
|
|
|
* @property array<int, string> $reviewAspect |
|
18
|
|
|
* @property array<int, string> $reviewBody |
|
19
|
|
|
* @property array<int, Rating> $reviewRating |
|
20
|
|
|
*/ |
|
21
|
|
|
class Review extends Base |
|
22
|
|
|
{ |
|
23
|
|
|
use DaftObjectTraits\HasReviewAspect; |
|
24
|
|
|
use DaftObjectTraits\HasItemReviewed; |
|
25
|
|
|
|
|
26
|
|
|
const SCHEMA_ORG_TYPE = 'Review'; |
|
27
|
|
|
|
|
28
|
|
|
const PROPERTIES = [ |
|
29
|
|
|
'itemReviewed', |
|
30
|
|
|
'reviewAspect', |
|
31
|
|
|
'reviewBody', |
|
32
|
|
|
'reviewRating', |
|
33
|
|
|
]; |
|
34
|
|
|
|
|
35
|
|
|
const PROPERTIES_WITH_MULTI_TYPED_ARRAYS = [ |
|
36
|
|
|
'itemReviewed' => TypeUtilities::MULTI_TYPE_DICT__itemReviewed, |
|
37
|
|
|
'reviewAspect' => TypeUtilities::MULTI_TYPE_DICT__reviewAspect, |
|
38
|
|
|
'reviewBody' => [ |
|
39
|
|
|
'string', |
|
40
|
|
|
], |
|
41
|
|
|
'reviewRating' => [ |
|
42
|
|
|
Rating::class, |
|
43
|
|
|
], |
|
44
|
|
|
]; |
|
45
|
|
|
|
|
46
|
|
|
/** |
|
47
|
|
|
* @return array<int, string> |
|
48
|
|
|
*/ |
|
49
|
65 |
|
public function GetReviewBody() : array |
|
50
|
|
|
{ |
|
51
|
|
|
/** |
|
52
|
|
|
* @var array<int, string> |
|
53
|
|
|
*/ |
|
54
|
65 |
|
$out = TypeUtilities::ExpectRetrievedValueIsArray( |
|
55
|
65 |
|
'reviewBody', |
|
56
|
65 |
|
$this->RetrievePropertyValueFromData('reviewBody'), |
|
57
|
65 |
|
static::class |
|
58
|
|
|
); |
|
59
|
|
|
|
|
60
|
65 |
|
return $out; |
|
61
|
|
|
} |
|
62
|
|
|
|
|
63
|
|
|
/** |
|
64
|
|
|
* @param array<int, string> $value |
|
65
|
|
|
*/ |
|
66
|
1 |
|
public function SetReviewBody(array $value) : void |
|
67
|
|
|
{ |
|
68
|
1 |
|
$this->NudgePropertyValue( |
|
69
|
1 |
|
'reviewBody', |
|
70
|
1 |
|
$value, |
|
71
|
1 |
|
true |
|
72
|
|
|
); |
|
73
|
1 |
|
} |
|
74
|
|
|
|
|
75
|
|
|
/** |
|
76
|
|
|
* @return array<int, Rating> |
|
77
|
|
|
*/ |
|
78
|
65 |
|
public function GetReviewRating() : array |
|
79
|
|
|
{ |
|
80
|
|
|
/** |
|
81
|
|
|
* @var array<int, Rating> |
|
82
|
|
|
*/ |
|
83
|
65 |
|
$out = TypeUtilities::ExpectRetrievedValueIsArray( |
|
84
|
65 |
|
'reviewRating', |
|
85
|
65 |
|
$this->RetrievePropertyValueFromData('reviewRating'), |
|
86
|
65 |
|
static::class |
|
87
|
|
|
); |
|
88
|
|
|
|
|
89
|
65 |
|
return $out; |
|
90
|
|
|
} |
|
91
|
|
|
|
|
92
|
|
|
/** |
|
93
|
|
|
* @param array<int, Rating> $value |
|
94
|
|
|
*/ |
|
95
|
1 |
|
public function SetReviewRating(array $value) : void |
|
96
|
|
|
{ |
|
97
|
1 |
|
$this->NudgePropertyValue( |
|
98
|
1 |
|
'reviewRating', |
|
99
|
1 |
|
$value |
|
100
|
|
|
); |
|
101
|
1 |
|
} |
|
102
|
|
|
} |
|
103
|
|
|
|