Article::GetWordCount()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 12
Code Lines 5

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 6
CRAP Score 1

Importance

Changes 0
Metric Value
cc 1
eloc 5
nc 1
nop 0
dl 0
loc 12
ccs 6
cts 6
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\CreativeWork;
8
9
use SignpostMarv\DaftObject\SchemaOrg\CreativeWork as Base;
10
use SignpostMarv\DaftObject\SchemaOrg\DaftObjectTraits;
11
use SignpostMarv\DaftObject\SchemaOrg\Intangible\SpeakableSpecification;
12
use SignpostMarv\DaftObject\SchemaOrg\TypeUtilities;
13
14
/**
15
* @property array<int, string> $articleBody
16
* @property array<int, string> $articleSection
17
* @property array<int, string|Base> $backstory
18
* @property array<int, int|string> $pageEnd
19
* @property array<int, int|string> $pageStart
20
* @property array<int, string> $pagination
21
* @property array<int, string|SpeakableSpecification> $speakable
22
* @property array<int, int|string> $wordCount
23
*/
24
class Article extends Base
25
{
26
    use DaftObjectTraits\HasSpeakable;
27
28
    const SCHEMA_ORG_TYPE = 'Article';
29
30
    const PROPERTIES = [
31
        'articleBody',
32
        'articleSection',
33
        'backstory',
34
        'pageEnd',
35
        'pageStart',
36
        'pagination',
37
        'speakable',
38
        'wordCount',
39
    ];
40
41
    const PROPERTIES_WITH_MULTI_TYPED_ARRAYS = [
42
        'articleBody' => [
43
            'string',
44
        ],
45
        'articleSection' => [
46
            'string',
47
        ],
48
        'backstory' => [
49
            'string',
50
            Base::class,
51
        ],
52
        'pageEnd' => [
53
            'integer',
54
            'string',
55
        ],
56
        'pageStart' => [
57
            'integer',
58
            'string',
59
        ],
60
        'pagination' => [
61
            'string',
62
        ],
63
        'speakable' => TypeUtilities::MULTI_TYPE_DICT__speakable,
64
        'wordCount' => [
65
            'integer',
66
            'string',
67
        ],
68
    ];
69
70
    /**
71
    * @return array<int, string>
72
    */
73 16
    public function GetArticleBody() : array
74
    {
75
        /**
76
        * @var array<int, string>
77
        */
78 16
        $out = TypeUtilities::ExpectRetrievedValueIsArray(
79 16
            'articleBody',
80 16
            $this->RetrievePropertyValueFromData('articleBody'),
81 16
            static::class
82
        );
83
84 16
        return $out;
85
    }
86
87
    /**
88
    * @param array<int, string> $value
89
    */
90 2
    public function SetArticleBody(array $value) : void
91
    {
92 2
        $this->NudgePropertyValue(
93 2
            'articleBody',
94 2
            $value,
95 2
            self::BOOL_DEFAULT_AUTOTRIMSTRINGS
96
        );
97 2
    }
98
99
    /**
100
    * @return array<int, string>
101
    */
102 16
    public function GetArticleSection() : array
103
    {
104
        /**
105
        * @var array<int, string>
106
        */
107 16
        $out = TypeUtilities::ExpectRetrievedValueIsArray(
108 16
            'articleSection',
109 16
            $this->RetrievePropertyValueFromData('articleSection'),
110 16
            static::class
111
        );
112
113 16
        return $out;
114
    }
115
116
    /**
117
    * @param array<int, string> $value
118
    */
119 2
    public function SetArticleSection(array $value) : void
120
    {
121 2
        $this->NudgePropertyValue(
122 2
            'articleSection',
123 2
            $value,
124 2
            self::BOOL_DEFAULT_AUTOTRIMSTRINGS
125
        );
126 2
    }
127
128
    /**
129
    * @return array<int, string|Base>
130
    */
131 16
    public function GetBackstory() : array
132
    {
133
        /**
134
        * @var array<int, string|Base>
135
        */
136 16
        $out = TypeUtilities::ExpectRetrievedValueIsArray(
137 16
            'backstory',
138 16
            $this->RetrievePropertyValueFromData('backstory'),
139 16
            static::class
140
        );
141
142 16
        return $out;
143
    }
144
145
    /**
146
    * @param array<int, string|Base> $value
147
    */
148 2
    public function SetBackstory(array $value) : void
149
    {
150 2
        $this->NudgePropertyValue(
151 2
            'backstory',
152 2
            $value,
153 2
            self::BOOL_DEFAULT_AUTOTRIMSTRINGS
154
        );
155 2
    }
156
157
    /**
158
    * @return array<int, int|string>
159
    */
160 16
    public function GetPageEnd() : array
161
    {
162
        /**
163
        * @var array<int, int|string>
164
        */
165 16
        $out = TypeUtilities::ExpectRetrievedValueIsArray(
166 16
            'pageEnd',
167 16
            $this->RetrievePropertyValueFromData('pageEnd'),
168 16
            static::class
169
        );
170
171 16
        return $out;
172
    }
173
174
    /**
175
    * @param array<int, int|string> $value
176
    */
177 2
    public function SetPageEnd(array $value) : void
178
    {
179 2
        $this->NudgePropertyValue(
180 2
            'pageEnd',
181 2
            $value,
182 2
            self::BOOL_DEFAULT_AUTOTRIMSTRINGS
183
        );
184 2
    }
185
186
    /**
187
    * @return array<int, int|string>
188
    */
189 16
    public function GetPageStart() : array
190
    {
191
        /**
192
        * @var array<int, int|string>
193
        */
194 16
        $out = TypeUtilities::ExpectRetrievedValueIsArray(
195 16
            'pageStart',
196 16
            $this->RetrievePropertyValueFromData('pageStart'),
197 16
            static::class
198
        );
199
200 16
        return $out;
201
    }
202
203
    /**
204
    * @param array<int, int|string> $value
205
    */
206 2
    public function SetPageStart(array $value) : void
207
    {
208 2
        $this->NudgePropertyValue(
209 2
            'pageStart',
210 2
            $value,
211 2
            self::BOOL_DEFAULT_AUTOTRIMSTRINGS
212
        );
213 2
    }
214
215
    /**
216
    * @return array<int, string>
217
    */
218 16
    public function GetPagination() : array
219
    {
220
        /**
221
        * @var array<int, string>
222
        */
223 16
        $out = TypeUtilities::ExpectRetrievedValueIsArray(
224 16
            'pagination',
225 16
            $this->RetrievePropertyValueFromData('pagination'),
226 16
            static::class
227
        );
228
229 16
        return $out;
230
    }
231
232
    /**
233
    * @param array<int, string> $value
234
    */
235 2
    public function SetPagination(array $value) : void
236
    {
237 2
        $this->NudgePropertyValue(
238 2
            'pagination',
239 2
            $value,
240 2
            self::BOOL_DEFAULT_AUTOTRIMSTRINGS
241
        );
242 2
    }
243
244
    /**
245
    * @return array<int, int>
246
    */
247 16
    public function GetWordCount() : array
248
    {
249
        /**
250
        * @var array<int, int>
251
        */
252 16
        $out = TypeUtilities::ExpectRetrievedValueIsArray(
253 16
            'wordCount',
254 16
            $this->RetrievePropertyValueFromData('wordCount'),
255 16
            static::class
256
        );
257
258 16
        return $out;
259
    }
260
261
    /**
262
    * @param array<int, int> $value
263
    */
264 2
    public function SetWordCount(array $value) : void
265
    {
266 2
        $this->NudgePropertyValue(
267 2
            'wordCount',
268 2
            $value
269
        );
270 2
    }
271
}
272