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

PostTypeBuilder::public()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 5
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

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