Passed
Branch fuzzy-generators (9f9b2f)
by SignpostMarv
11:06
created

Rating   A

Complexity

Total Complexity 6

Size/Duplication

Total Lines 119
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
eloc 52
dl 0
loc 119
ccs 35
cts 35
cp 1
rs 10
c 0
b 0
f 0
wmc 6

6 Methods

Rating   Name   Duplication   Size   Complexity  
A GetRatingValue() 0 12 1
A GetWorstRating() 0 12 1
A GetBestRating() 0 12 1
A SetRatingValue() 0 6 1
A SetBestRating() 0 6 1
A SetWorstRating() 0 6 1
1
<?php
2
/**
3
* @author SignpostMarv
4
*/
5
declare(strict_types=1);
6
7
namespace SignpostMarv\DaftObject\SchemaOrg\Intangible;
8
9
use SignpostMarv\DaftObject\SchemaOrg\DaftObjectTraits;
10
use SignpostMarv\DaftObject\SchemaOrg\Intangible as Base;
11
use SignpostMarv\DaftObject\SchemaOrg\TypeUtilities;
12
13
/**
14
* @property array<int, \SignpostMarv\DaftObject\SchemaOrg\Organization|\SignpostMarv\DaftObject\SchemaOrg\Person> $author
15
* @property array<int, string|float|int> $bestRating
16
* @property array<int, string|float|int> $ratingValue
17
* @property array<int, string> $reviewAspect
18
* @property array<int, string|float|int> $worstRating
19
*/
20
class Rating extends Base
21
{
22
    use DaftObjectTraits\HasAuthor;
23
    use DaftObjectTraits\HasReviewAspect;
24
25
    const SCHEMA_ORG_TYPE = 'Rating';
26
27
    const PROPERTIES = [
28
        'author',
29
        'bestRating',
30
        'ratingValue',
31
        'reviewAspect',
32
        'worstRating',
33
    ];
34
35
    const PROPERTIES_WITH_MULTI_TYPED_ARRAYS = [
36
        'author' => TypeUtilities::MULTI_TYPE_DICT__author,
37
        'bestRating' => [
38
            'string',
39
            'double',
40
            'integer',
41
        ],
42
        'ratingValue' => [
43
            'string',
44
            'double',
45
            'integer',
46
        ],
47
        'reviewAspect' => TypeUtilities::MULTI_TYPE_DICT__reviewAspect,
48
        'worstRating' => [
49
            'string',
50
            'double',
51
            'integer',
52
        ],
53
    ];
54
55
    /**
56
    * @return array<int, string|float|int>
57
    */
58 69
    public function GetBestRating() : array
59
    {
60
        /**
61
        * @var array<int, string|float|int>
62
        */
63 69
        $out = TypeUtilities::ExpectRetrievedValueIsArray(
64 69
            'bestRating',
65 69
            $this->RetrievePropertyValueFromData('bestRating'),
66 69
            static::class
67
        );
68
69 69
        return $out;
70
    }
71
72
    /**
73
    * @param array<int, string|float|int> $value
74
    */
75 3
    public function SetBestRating(array $value) : void
76
    {
77 3
        $this->NudgePropertyValue(
78 3
            'bestRating',
79 3
            $value,
80 3
            true
81
        );
82 3
    }
83
84
    /**
85
    * @return array<int, string|float|int>
86
    */
87 69
    public function GetRatingValue() : array
88
    {
89
        /**
90
        * @var array<int, string|float|int>
91
        */
92 69
        $out = TypeUtilities::ExpectRetrievedValueIsArray(
93 69
            'ratingValue',
94 69
            $this->RetrievePropertyValueFromData('ratingValue'),
95 69
            static::class
96
        );
97
98 69
        return $out;
99
    }
100
101
    /**
102
    * @param array<int, string|float|int> $value
103
    */
104 3
    public function SetRatingValue(array $value) : void
105
    {
106 3
        $this->NudgePropertyValue(
107 3
            'ratingValue',
108 3
            $value,
109 3
            true
110
        );
111 3
    }
112
113
    /**
114
    * @return array<int, string|float|int>
115
    */
116 69
    public function GetWorstRating() : array
117
    {
118
        /**
119
        * @var array<int, string|float|int>
120
        */
121 69
        $out = TypeUtilities::ExpectRetrievedValueIsArray(
122 69
            'worstRating',
123 69
            $this->RetrievePropertyValueFromData('worstRating'),
124 69
            static::class
125
        );
126
127 69
        return $out;
128
    }
129
130
    /**
131
    * @param array<int, string|float|int> $value
132
    */
133 3
    public function SetWorstRating(array $value) : void
134
    {
135 3
        $this->NudgePropertyValue(
136 3
            'worstRating',
137 3
            $value,
138 3
            true
139
        );
140 3
    }
141
}
142