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

ContactPoint   A

Complexity

Total Complexity 6

Size/Duplication

Total Lines 144
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
eloc 71
dl 0
loc 144
ccs 37
cts 37
cp 1
rs 10
c 0
b 0
f 0
wmc 6

6 Methods

Rating   Name   Duplication   Size   Complexity  
A SetContactType() 0 6 1
A GetContactType() 0 12 1
A SetContactOption() 0 7 1
A GetContactOption() 0 12 1
A GetProductSupported() 0 12 1
A SetProductSupported() 0 7 1
1
<?php
2
/**
3
* @author SignpostMarv
4
*/
5
declare(strict_types=1);
6
7
namespace SignpostMarv\DaftObject\SchemaOrg\Intangible\StructuredValue;
8
9
use SignpostMarv\DaftObject\SchemaOrg\DaftObjectTraits;
10
use SignpostMarv\DaftObject\SchemaOrg\GeoShape;
11
use SignpostMarv\DaftObject\SchemaOrg\Intangible\Enumeration\ContactPointOption;
12
use SignpostMarv\DaftObject\SchemaOrg\Intangible\Language;
13
use SignpostMarv\DaftObject\SchemaOrg\Intangible\StructuredValue as Base;
14
use SignpostMarv\DaftObject\SchemaOrg\Place;
15
use SignpostMarv\DaftObject\SchemaOrg\Place\AdministrativeArea;
16
use SignpostMarv\DaftObject\SchemaOrg\Product;
17
use SignpostMarv\DaftObject\SchemaOrg\TypeUtilities;
18
19
/**
20
* @property array<int, string|AdministrativeArea|GeoShape|Place> $areaServed
21
* @property array<int, string|Language> $availableLanguage
22
* @property array<int, ContactPointOption> $contactOption
23
* @property array<int, string> $contactType
24
* @property array<int, string> $email
25
* @property array<int, string> $faxNumber
26
* @property array<int, OpeningHoursSpecification> $hoursAvailable
27
* @property array<int, string|Product> $productSupported
28
* @property array<int, string> $telephone
29
*/
30
class ContactPoint extends Base
31
{
32
    use DaftObjectTraits\HasAreaServed;
33
    use DaftObjectTraits\AvailableLanguage;
34
    use DaftObjectTraits\HasEmail;
35
    use DaftObjectTraits\HasFaxNumber;
36
    use DaftObjectTraits\HasHoursAvailable;
37
    use DaftObjectTraits\HasTelephone;
38
39
    const SCHEMA_ORG_TYPE = 'ContactPoint';
40
41
    const PROPERTIES = [
42
        'areaServed',
43
        'availableLanguage',
44
        'contactOption',
45
        'contactType',
46
        'email',
47
        'faxNumber',
48
        'hoursAvailable',
49
        'productSupported',
50
        'telephone',
51
    ];
52
53
    const PROPERTIES_WITH_MULTI_TYPED_ARRAYS = [
54
        'areaServed' => [
55
            'string',
56
            AdministrativeArea::class,
57
            GeoShape::class,
58
            Place::class,
59
        ],
60
        'availableLanguage' => [
61
            'string',
62
            Language::class,
63
        ],
64
        'contactOption' => [
65
            ContactPointOption::class,
66
        ],
67
        'contactType' => [
68
            'string',
69
        ],
70
        'email' => [
71
            'string',
72
        ],
73
        'faxNumber' => [
74
            'string',
75
        ],
76
        'hoursAvailable' => [
77
            OpeningHoursSpecification::class,
78
        ],
79
        'productSupported' => [
80
            'string',
81
            Product::class,
82
        ],
83
        'telephone' => [
84
            'string',
85
        ],
86
    ];
87
88
    /**
89
    * @return array<int, ContactPointOption>
90
    */
91 22
    public function GetContactOption() : array
92
    {
93
        /**
94
        * @var array<int, ContactPointOption>
95
        */
96 22
        $out = TypeUtilities::ExpectRetrievedValueIsArray(
97 22
            'contactOption',
98 22
            $this->RetrievePropertyValueFromData('contactOption'),
99 22
            static::class
100
        );
101
102 22
        return $out;
103
    }
104
105
    /**
106
    * @param array<int, ContactPointOption> $value
107
    */
108 3
    public function SetContactOption(array $value) : void
109
    {
110 3
        $this->NudgePropertyWithUniqueValuesOfThings(
111 3
            'contactOption',
112 3
            __METHOD__,
113 3
            $value,
114 3
            ContactPointOption::class
115
        );
116 3
    }
117
118
    /**
119
    * @return array<int, string>
120
    */
121 22
    public function GetContactType() : array
122
    {
123
        /**
124
        * @var array<int, string>
125
        */
126 22
        $out = TypeUtilities::ExpectRetrievedValueIsArray(
127 22
            'contactType',
128 22
            $this->RetrievePropertyValueFromData('contactType'),
129 22
            static::class
130
        );
131
132 22
        return $out;
133
    }
134
135
    /**
136
    * @param array<int, string> $value
137
    */
138 3
    public function SetContactType(array $value) : void
139
    {
140 3
        $this->NudgePropertyWithUniqueTrimmedStringsMightNotBeString(
141 3
            'contactType',
142 3
            __METHOD__,
143 3
            $value
144
        );
145 3
    }
146
147
    /**
148
    * @return array<int, string|Product>
149
    */
150 22
    public function GetProductSupported() : array
151
    {
152
        /**
153
        * @var array<int, string|Product>
154
        */
155 22
        $out = TypeUtilities::ExpectRetrievedValueIsArray(
156 22
            'productSupported',
157 22
            $this->RetrievePropertyValueFromData('productSupported'),
158 22
            static::class
159
        );
160
161 22
        return $out;
162
    }
163
164
    /**
165
    * @param array<int, string|Product> $value
166
    */
167 3
    public function SetProductSupported(array $value) : void
168
    {
169 3
        $this->NudgePropertyWithUniqueTrimmedStringsOrThings(
170 3
            'productSupported',
171 3
            __METHOD__,
172 3
            $value,
173 3
            Product::class
174
        );
175 3
    }
176
}
177