AdaptedPostType   A
last analyzed

Complexity

Total Complexity 39

Size/Duplication

Total Lines 197
Duplicated Lines 0 %

Test Coverage

Coverage 0%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 41
dl 0
loc 197
ccs 0
cts 78
cp 0
rs 9.28
c 1
b 0
f 0
wmc 39

39 Methods

Rating   Name   Duplication   Size   Complexity  
A getQueryVar() 0 3 1
A isAllowedInUi() 0 3 1
A canBeExported() 0 3 1
A getTemplate() 0 3 1
A getRestControllerClass() 0 3 1
A getTaxonomies() 0 3 1
A allowsMetaCapMapping() 0 3 1
A isAllowedInAdminBar() 0 3 1
A getName() 0 3 1
A getShowUi() 0 3 1
A getCapabilityType() 0 3 1
A getSupports() 0 3 1
A getPubliclyQueryable() 0 3 1
A isAllowedInRest() 0 3 1
A getDescription() 0 3 1
A fromName() 0 3 1
A getSingularLabel() 0 3 1
A getRegisterMetaBoxCb() 0 3 1
A getRestBase() 0 3 1
A getOptions() 0 3 1
A getPluralLabel() 0 3 1
A getLabel() 0 3 1
A getArchive() 0 3 1
A getDisplayedInMenu() 0 3 1
A getRewrite() 0 3 1
A isDeletedWithUser() 0 3 1
A getRestNamespace() 0 3 1
A getTemplateLock() 0 3 1
A isPublic() 0 3 1
A isPubliclyQueryable() 0 3 1
A getShowInMenu() 0 3 1
A isHierarchical() 0 3 1
A getLabels() 0 3 1
A isAllowedInNavMenus() 0 3 1
A getCapabilities() 0 3 1
A isExcludedFromSearch() 0 3 1
A __construct() 0 3 1
A getMenuPosition() 0 3 1
A getMenuIcon() 0 3 1
1
<?php
2
3
namespace Leonidas\Library\System\Model\PostType;
4
5
use Leonidas\Contracts\System\Model\PostType\PostTypeInterface;
6
use WP_Post_Type;
0 ignored issues
show
Bug introduced by
The type WP_Post_Type was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
7
8
class AdaptedPostType implements PostTypeInterface
9
{
10
    protected WP_Post_Type $postType;
11
12
    public function __construct(WP_Post_Type $postType)
13
    {
14
        $this->postType = $postType;
15
    }
16
17
    public function getName(): string
18
    {
19
        return $this->postType->name;
20
    }
21
22
    public function getLabel(): string
23
    {
24
        return $this->postType->label;
25
    }
26
27
    public function getDescription(): string
28
    {
29
        return $this->postType->description;
30
    }
31
32
    public function isPublic(): bool
33
    {
34
        return $this->postType->public;
35
    }
36
37
    public function getPubliclyQueryable(): bool
38
    {
39
        return $this->postType->publicly_queryable;
40
    }
41
42
    public function getShowUi(): bool
43
    {
44
        return $this->postType->show_ui;
45
    }
46
47
    public function getShowInMenu(): bool
48
    {
49
        return $this->postType->show_in_menu;
50
    }
51
52
    public function getMenuPosition(): ?int
53
    {
54
        return $this->postType->menu_position;
55
    }
56
57
    public function getMenuIcon(): ?string
58
    {
59
        return $this->postType->menu_icon;
60
    }
61
62
    public function getCapabilityType(): string
63
    {
64
        return $this->postType->capability_type;
65
    }
66
67
    public function getSupports(): array
68
    {
69
        return $this->postType->supports;
70
    }
71
72
    public function getTaxonomies(): array
73
    {
74
        return $this->postType->taxonomies;
75
    }
76
77
    public function getArchive(): ?string
78
    {
79
        return $this->postType->has_archive;
80
    }
81
82
    public function canBeExported(): bool
83
    {
84
        return $this->postType->can_export;
85
    }
86
87
    public function isDeletedWithUser(): ?bool
88
    {
89
        return $this->postType->delete_with_user;
90
    }
91
92
    public function getTemplate(): array
93
    {
94
        return $this->postType->template;
95
    }
96
97
    public function getTemplateLock(): ?string
98
    {
99
        return $this->postType->template_lock;
100
    }
101
102
    public function isExcludedFromSearch(): bool
103
    {
104
        return $this->postType->exclude_from_search;
105
    }
106
107
    public function isAllowedInAdminBar(): bool
108
    {
109
        return $this->postType->show_in_admin_bar;
110
    }
111
112
    public function allowsMetaCapMapping(): bool
113
    {
114
        return $this->postType->map_meta_cap;
115
    }
116
117
    public function getRegisterMetaBoxCb(): ?callable
118
    {
119
        return $this->postType->register_meta_box_cb;
120
    }
121
122
    public function getRewrite(): array
123
    {
124
        return $this->postType->rewrite;
125
    }
126
127
    public function getQueryVar(): string
128
    {
129
        return $this->postType->query_var;
130
    }
131
132
    public function isAllowedInNavMenus(): bool
133
    {
134
        return $this->postType->show_in_nav_menus;
135
    }
136
137
    public function getRestBase(): string
138
    {
139
        return $this->postType->rest_base;
140
    }
141
142
    public function getRestControllerClass(): string
143
    {
144
        return $this->postType->rest_controller_class;
145
    }
146
147
    public function isAllowedInRest(): bool
148
    {
149
        return $this->postType->show_in_rest;
150
    }
151
152
    public function isAllowedInUi(): bool
153
    {
154
        return $this->postType->show_ui;
155
    }
156
157
    public function getLabels(): array
158
    {
159
        return (array) $this->postType->labels;
160
    }
161
162
    public function getSingularLabel(): string
163
    {
164
        return $this->postType->labels->singular_name;
165
    }
166
167
    public function getPluralLabel(): string
168
    {
169
        return $this->postType->labels->name;
170
    }
171
172
    public function getRestNamespace(): string
173
    {
174
        return $this->postType->rest_namespace;
175
    }
176
177
    public function getCapabilities(): array
178
    {
179
        return (array) $this->postType->cap;
180
    }
181
182
    public function getDisplayedInMenu()
183
    {
184
        return $this->postType->show_in_menu;
185
    }
186
187
    public function getOptions(): array
188
    {
189
        return $this->postType->options ?? [];
190
    }
191
192
    public function isHierarchical(): bool
193
    {
194
        return $this->postType->hierarchical;
195
    }
196
197
    public function isPubliclyQueryable(): bool
198
    {
199
        return $this->postType->publicly_queryable;
200
    }
201
202
    public static function fromName(string $name): PostTypeInterface
203
    {
204
        return new self(get_post_type_object($name));
0 ignored issues
show
Bug introduced by
The function get_post_type_object was not found. Maybe you did not declare it correctly or list all dependencies? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

204
        return new self(/** @scrutinizer ignore-call */ get_post_type_object($name));
Loading history...
205
    }
206
}
207