Test Failed
Push — master ( fdb79d...2e4512 )
by Chris
19:35
created

TaxonomyBuilder::get()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 31
Code Lines 29

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 29
dl 0
loc 31
rs 9.456
c 1
b 0
f 0
cc 1
nc 1
nop 0
1
<?php
2
3
namespace Leonidas\Library\System\Taxonomy;
4
5
use Leonidas\Contracts\System\Taxonomy\TaxonomyBuilderInterface;
6
use Leonidas\Library\System\AbstractSystemModelTypeBuilder;
7
8
class TaxonomyBuilder extends AbstractSystemModelTypeBuilder implements TaxonomyBuilderInterface
9
{
10
    protected array $objectTypes;
11
12
    protected ?bool $isShownInTagCloud;
13
14
    protected ?bool $isShownInQuickEdit;
15
16
    protected ?bool $showsAdminColumn;
17
18
    /**
19
     * @var null|bool|callable
20
     */
21
    protected $metaBoxCb;
22
23
    /**
24
     * @var null|callable
25
     */
26
    protected $metaBoxSanitizeCb;
27
28
    /**
29
     * @var null|callable
30
     */
31
    protected $updateCountCallback;
32
33
    /**
34
     * @var null|string|array
35
     */
36
    protected $defaultTerm;
37
38
    protected ?bool $shouldBeSorted;
39
40
    /**
41
     * @return null|array
42
     */
43
    protected $args;
44
45
    public function name(string $name): self
46
    {
47
        $this->name = $name;
48
49
        return $this;
50
    }
51
52
    public function plural(string $pluralLabel): self
53
    {
54
        $this->pluralLabel = $pluralLabel;
55
56
        return $this;
57
    }
58
59
    public function singular(?string $singularLabel): self
60
    {
61
        $this->singularLabel = $singularLabel;
62
63
        return $this;
64
    }
65
66
    public function description(?string $description): self
67
    {
68
        $this->description = $description;
69
70
        return $this;
71
    }
72
73
    public function labels(?array $labels): self
74
    {
75
        $this->labels = $labels;
76
77
        return $this;
78
    }
79
80
    public function public(?bool $isPublic): self
81
    {
82
        $this->isPublic = $isPublic;
83
84
        return $this;
85
    }
86
87
    public function hierarchical(?bool $isHierarchical): self
88
    {
89
        $this->isHierarchical = $isHierarchical;
90
91
        return $this;
92
    }
93
94
    public function publiclyQueryable(?bool $isPubliclyQueryable): self
95
    {
96
        $this->isPubliclyQueryable = $isPubliclyQueryable;
97
98
        return $this;
99
    }
100
101
    public function showInUi(?bool $showInUi): self
102
    {
103
        $this->isShownInUi = $showInUi;
104
105
        return $this;
106
    }
107
108
    public function showInMenu($showInMenu): self
109
    {
110
        $this->showInMenu = $showInMenu;
0 ignored issues
show
Bug Best Practice introduced by
The property showInMenu does not exist. Although not strictly required by PHP, it is generally a best practice to declare properties explicitly.
Loading history...
111
112
        return $this;
113
    }
114
115
    public function showInNavMenus(?bool $showInNavMenu): self
116
    {
117
        $this->shownInMenus = $showInNavMenu;
118
119
        return $this;
120
    }
121
122
    public function capabilities(?array $capabilities): self
123
    {
124
        $this->capabilities = $capabilities;
125
126
        return $this;
127
    }
128
129
    public function rewrite($rewrite): self
130
    {
131
        $this->rewrite = $rewrite;
132
133
        return $this;
134
    }
135
136
    public function queryVar($queryVar): self
137
    {
138
        $this->queryVar = $queryVar;
139
140
        return $this;
141
    }
142
143
    public function showInRest(?bool $showInRest): self
144
    {
145
        $this->isShownInRest = $showInRest;
146
147
        return $this;
148
    }
149
150
    public function restBase(?string $restBase): self
151
    {
152
        $this->restBase = $restBase;
153
154
        return $this;
155
    }
156
157
    public function restNamespace(?string $restNamespace): self
158
    {
159
        $this->restNamespace = $restNamespace;
160
161
        return $this;
162
    }
163
164
    public function restControllerClass(?string $restControllerClass): self
165
    {
166
        $this->restControllerClass = $restControllerClass;
167
168
        return $this;
169
    }
170
171
    public function options(?array $extraArgs): self
172
    {
173
        $this->options = $extraArgs;
174
175
        return $this;
176
    }
177
178
    public function objectTypes(string ...$objectTypes): self
179
    {
180
        $this->objectTypes = $objectTypes;
181
182
        return $this;
183
    }
184
185
    public function showTagCloud(?bool $showInTagCloud): self
186
    {
187
        $this->isShownInTagCloud = $showInTagCloud;
188
189
        return $this;
190
    }
191
192
    public function showInQuickEdit(?bool $showInQuickEdit): self
193
    {
194
        $this->isShownInQuickEdit = $showInQuickEdit;
195
196
        return $this;
197
    }
198
199
    public function showAdminColumn(?bool $showAdminColumn): self
200
    {
201
        $this->showsAdminColumn = $showAdminColumn;
202
203
        return $this;
204
    }
205
206
    public function metaBoxCb($metaBoxCb): self
207
    {
208
        $this->metaBoxCb = $metaBoxCb;
209
210
        return $this;
211
    }
212
213
    public function metaBoxSanitizeCb(?callable $metaBoxSanitizeCb): self
214
    {
215
        $this->metaBoxSanitizeCb = $metaBoxSanitizeCb;
216
217
        return $this;
218
    }
219
220
    public function updateCountCallback(?callable $updateCountCallback): self
221
    {
222
        $this->updateCountCallback = $updateCountCallback;
223
224
        return $this;
225
    }
226
227
    public function defaultTerm($defaultTerm): self
228
    {
229
        $this->defaultTerm = $defaultTerm;
230
231
        return $this;
232
    }
233
234
    public function sort(?bool $sorted): self
235
    {
236
        $this->shouldBeSorted = $sorted;
237
238
        return $this;
239
    }
240
241
    public function args(?array $args): self
242
    {
243
        $this->args = $args;
244
245
        return $this;
246
    }
247
248
    public function get(): Taxonomy
249
    {
250
        return new Taxonomy(
251
            $this->name,
252
            $this->objectTypes,
253
            $this->pluralLabel,
254
            $this->singularLabel,
255
            $this->description ?? '',
256
            $this->labels ?? [],
257
            $this->isPublic ?? false,
258
            $this->isHierarchical ?? false,
259
            $this->isPubliclyQueryable,
260
            $this->isShownInUi,
261
            $this->shownInMenus,
262
            $this->isShownInNavMenus,
263
            $this->capabilities ?? [],
264
            $this->rewrite ?? true,
265
            $this->queryVar ?? true,
266
            $this->isShownInRest ?? false,
267
            $this->restBase ?? false,
268
            $this->restNamespace ?? false,
269
            $this->restControllerClass ?? false,
270
            $this->isShownInTagCloud,
271
            $this->isShownInQuickEdit,
272
            $this->showsAdminColumn ?? false,
273
            $this->metaBoxCb,
274
            $this->metaBoxSanitizeCb,
275
            $this->updateCountCallback,
276
            $this->defaultTerm,
277
            $this->shouldBeSorted,
278
            $this->options ?? []
279
        );
280
    }
281
282
    public static function for(string $name): self
283
    {
284
        return new self($name);
285
    }
286
}
287