Metabox::getTitle()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 0
Metric Value
cc 1
eloc 1
nc 1
nop 0
dl 0
loc 3
ccs 0
cts 2
cp 0
crap 2
rs 10
c 0
b 0
f 0
1
<?php
2
3
namespace Leonidas\Library\Admin\Component\Metabox;
4
5
use Leonidas\Contracts\Admin\Component\Metabox\MetaboxInterface;
6
use Leonidas\Contracts\Admin\Component\Metabox\MetaboxLayoutInterface;
7
use Leonidas\Library\Admin\Abstracts\CanBeRestrictedTrait;
8
use Leonidas\Library\Admin\Component\Metabox\Layout\SegmentedLayout;
9
use Leonidas\Library\Core\Http\Policy\NoPolicy;
10
use Psr\Http\Message\ServerRequestInterface;
11
use WebTheory\HttpPolicy\ServerRequestPolicyInterface;
12
use WP_Screen;
0 ignored issues
show
Bug introduced by
The type WP_Screen 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...
13
14
class Metabox implements MetaboxInterface
15
{
16
    use CanBeRestrictedTrait;
17
18
    protected string $id;
19
20
    protected string $title;
21
22
    /**
23
     * @var string|string[]|WP_Screen
24
     */
25
    protected $screen;
26
27
    protected string $context = 'advanced';
28
29
    protected string $priority = 'default';
30
31
    protected MetaboxLayoutInterface $layout;
32
33
    protected array $args;
34
35
    public function __construct(
36
        string $id,
37
        string $title,
38
        string $screen,
39
        ?string $context = null,
40
        ?string $priority = null,
41
        array $args = [],
42
        ?MetaboxLayoutInterface $layout = null,
43
        ?ServerRequestPolicyInterface $policy = null
44
    ) {
45
        $this->id = $id;
46
        $this->title = $title;
47
        $this->screen = $screen;
48
        $this->context = $context ?? $this->context;
49
        $this->priority = $priority ?? $this->priority;
50
        $this->args = $args;
51
        $this->layout = $layout;
52
53
        $this->layout = $layout ?? new SegmentedLayout();
54
        $this->policy = $policy ?? new NoPolicy();
55
    }
56
57
    /**
58
     * Get id
59
     *
60
     * @return string
61
     */
62
    public function getId(): string
63
    {
64
        return $this->id;
65
    }
66
67
    /**
68
     * Get title
69
     *
70
     * @return string
71
     */
72
    public function getTitle(): string
73
    {
74
        return $this->title;
75
    }
76
77
    /**
78
     * Get screen
79
     *
80
     * @return string|string[]|WP_Screen
81
     */
82
    public function getScreen()
83
    {
84
        return $this->screen;
85
    }
86
87
    /**
88
     * Get context
89
     *
90
     * @return string
91
     */
92
    public function getContext(): string
93
    {
94
        return $this->context;
95
    }
96
97
    /**
98
     * Get priority
99
     *
100
     * @return string
101
     */
102
    public function getPriority(): string
103
    {
104
        return $this->priority;
105
    }
106
107
    /**
108
     * Get args
109
     *
110
     * @return array
111
     */
112
    public function getArgs(): array
113
    {
114
        return $this->args;
115
    }
116
117
    /**
118
     * Get layout
119
     *
120
     * @return MetaboxLayoutInterface
121
     */
122
    public function getLayout(): MetaboxLayoutInterface
123
    {
124
        return $this->layout;
125
    }
126
127
    public function renderComponent(ServerRequestInterface $request): string
128
    {
129
        return $this->layout->renderComponent($request);
130
    }
131
}
132