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

AbstractSystemModelType::getRestNamespace()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 1
dl 0
loc 3
rs 10
c 1
b 0
f 0
cc 1
nc 1
nop 0
1
<?php
2
3
namespace Leonidas\Library\System;
4
5
use Leonidas\Contracts\System\BaseSystemModelTypeInterface;
6
7
abstract class AbstractSystemModelType implements BaseSystemModelTypeInterface
8
{
9
    protected string $name;
10
11
    protected string $singularLabel;
12
13
    protected string $pluralLabel;
14
15
    protected string $description;
16
17
    protected array $labels;
18
19
    protected bool $isPublic;
20
21
    protected bool $isHierarchical;
22
23
    protected bool $isPubliclyQueryable;
24
25
    protected bool $isShownInUi;
26
27
    /**
28
     * @var bool|string
29
     */
30
    protected $shownInMenu;
31
32
    protected bool $isShownInNavMenus;
33
34
    protected array $capabilities;
35
36
    /**
37
     * @var bool|array
38
     */
39
    protected $rewrite;
40
41
    /**
42
     * @var bool|string
43
     */
44
    protected $queryVar;
45
46
    protected bool $isShownInRest;
47
48
    /**
49
     * @var bool|string
50
     */
51
    protected $restBase;
52
53
    /**
54
     * @var bool|string
55
     */
56
    protected $restNamespace;
57
58
    /**
59
     * @var bool|string
60
     */
61
    protected $restControllerClass;
62
63
    protected array $options;
64
65
    public function __construct(
66
        string $name,
67
        string $pluralLabel,
68
        string $singularLabel,
69
        string $description = '',
70
        array $labels = [],
71
        bool $isPublic = false,
72
        bool $isHierarchical = false,
73
        ?bool $isPubliclyQueryable = null,
74
        ?bool $isShownInUi = null,
75
        $shownInMenu = null,
76
        ?bool $isShownInNavMenus = null,
77
        array $capabilities = [],
78
        $rewrite = true,
79
        $queryVar = true,
80
        bool $isShownInRest = false,
81
        $restBase = false,
82
        $restNamespace = false,
83
        $restControllerClass = false,
84
        array $options = []
85
    ) {
86
        $this->name = $name;
87
        $this->pluralLabel = $pluralLabel;
88
        $this->description = $description;
89
        $this->labels = $labels + $this->defaultLabels();
90
        $this->isPublic = $isPublic;
91
        $this->isHierarchical = $isHierarchical;
92
        $this->capabilities = $capabilities;
93
        $this->rewrite = $rewrite;
94
        $this->queryVar = $queryVar;
95
        $this->isShownInRest = $isShownInRest;
96
        $this->restBase = $restBase;
97
        $this->restNamespace = $restNamespace;
98
        $this->restControllerClass = $restControllerClass;
99
        $this->options = $options;
100
101
        $this->singularLabel = $singularLabel ?? $this->pluralLabel;
102
        $this->isPubliclyQueryable = $isPubliclyQueryable ?? $this->isPublic;
103
        $this->isShownInUi = $isShownInUi ?? $this->isPublic;
104
        $this->shownInMenu = $shownInMenu ?? $this->isShownInUi;
105
        $this->isShownInNavMenus = $isShownInNavMenus ?? $this->isPublic;
106
    }
107
108
    public function getName(): string
109
    {
110
        return $this->name;
111
    }
112
113
    public function getPluralLabel(): string
114
    {
115
        return $this->pluralLabel;
116
    }
117
118
    public function getSingularLabel(): string
119
    {
120
        return $this->singularLabel;
121
    }
122
123
    public function getDescription(): string
124
    {
125
        return $this->description;
126
    }
127
128
    public function getLabels(): array
129
    {
130
        return $this->labels;
131
    }
132
133
    public function getCapabilities(): array
134
    {
135
        return $this->capabilities;
136
    }
137
138
    public function isPublic(): bool
139
    {
140
        return $this->isPublic;
141
    }
142
143
    public function isHierarchical(): bool
144
    {
145
        return $this->isHierarchical;
146
    }
147
148
    public function isPubliclyQueryable(): bool
149
    {
150
        return $this->isPubliclyQueryable;
151
    }
152
153
    public function isShownInUi(): bool
154
    {
155
        return $this->isShownInUi;
156
    }
157
158
    public function getShownInMenu()
159
    {
160
        return $this->shownInMenu;
161
    }
162
163
    public function isShownInNavMenus(): bool
164
    {
165
        return $this->isShownInNavMenus;
166
    }
167
168
    public function getRewrite()
169
    {
170
        return $this->rewrite;
171
    }
172
173
    public function getQueryVar()
174
    {
175
        return $this->queryVar;
176
    }
177
178
    public function isShownInRest(): bool
179
    {
180
        return $this->isShownInRest;
181
    }
182
183
    public function getRestBase()
184
    {
185
        return $this->restBase;
186
    }
187
188
    public function getRestNamespace()
189
    {
190
        return $this->restNamespace;
191
    }
192
193
    public function getRestControllerClass()
194
    {
195
        return $this->restControllerClass;
196
    }
197
198
    public function getOptions(): array
199
    {
200
        return $this->options;
201
    }
202
203
    abstract protected function defaultLabels(): array;
204
}
205