Test Failed
Push — master ( 2c2c87...ed1c51 )
by Chris
25:05 queued 37s
created

SettingBuilder::optionGroup()   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
c 1
b 0
f 0
dl 0
loc 3
rs 10
cc 1
nc 1
nop 1
1
<?php
2
3
namespace Leonidas\Library\Admin\Setting;
4
5
use Leonidas\Contracts\Admin\Setting\SettingBuilderInterface;
6
use Leonidas\Contracts\Admin\Setting\SettingHandlerInterface;
7
use Leonidas\Library\Admin\Setting\Traits\HasSettingsTrait;
0 ignored issues
show
Bug introduced by
The type Leonidas\Library\Admin\S...Traits\HasSettingsTrait 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...
8
9
class SettingBuilder implements SettingBuilderInterface
10
{
11
    use HasSettingsTrait;
12
13
    protected ?SettingHandlerInterface $handler = null;
14
15
    public function __construct(string $optionName)
16
    {
17
        $this->optionName = $optionName;
0 ignored issues
show
Bug Best Practice introduced by
The property optionName does not exist. Although not strictly required by PHP, it is generally a best practice to declare properties explicitly.
Loading history...
18
    }
19
20
    public function optionGroup(string $optionGroup)
21
    {
22
        $this->optionGroup = $optionGroup;
0 ignored issues
show
Bug Best Practice introduced by
The property optionGroup does not exist. Although not strictly required by PHP, it is generally a best practice to declare properties explicitly.
Loading history...
23
    }
24
25
    public function optionName(string $optionName)
26
    {
27
        $this->optionName = $optionName;
0 ignored issues
show
Bug Best Practice introduced by
The property optionName does not exist. Although not strictly required by PHP, it is generally a best practice to declare properties explicitly.
Loading history...
28
    }
29
30
    public function type(?string $type)
31
    {
32
        $this->type = $type;
0 ignored issues
show
Bug Best Practice introduced by
The property type does not exist. Although not strictly required by PHP, it is generally a best practice to declare properties explicitly.
Loading history...
33
    }
34
35
    public function description(?string $description)
36
    {
37
        $this->description = $description;
0 ignored issues
show
Bug Best Practice introduced by
The property description does not exist. Although not strictly required by PHP, it is generally a best practice to declare properties explicitly.
Loading history...
38
    }
39
40
    public function schema($schema)
41
    {
42
        $this->restSchema = $schema;
0 ignored issues
show
Bug Best Practice introduced by
The property restSchema does not exist. Although not strictly required by PHP, it is generally a best practice to declare properties explicitly.
Loading history...
43
    }
44
45
    public function default($default)
46
    {
47
        $this->defaultValue = $default;
0 ignored issues
show
Bug Best Practice introduced by
The property defaultValue does not exist. Although not strictly required by PHP, it is generally a best practice to declare properties explicitly.
Loading history...
48
    }
49
50
    public function extra(?array $extraArgs)
51
    {
52
        $this->extraArgs = $extraArgs;
0 ignored issues
show
Bug Best Practice introduced by
The property extraArgs does not exist. Although not strictly required by PHP, it is generally a best practice to declare properties explicitly.
Loading history...
53
    }
54
55
    public function handler(?SettingHandlerInterface $handler)
56
    {
57
        $this->handler = $handler;
58
    }
59
60
    public function getHandler(): ?SettingHandlerInterface
61
    {
62
        return $this->handler;
63
    }
64
65
    public function get(): Setting
66
    {
67
        return new Setting(
68
            $this->getOptionGroup(),
69
            $this->getOptionName(),
70
            $this->getType(),
71
            $this->getDescription(),
72
            $this->getHandler(),
73
            $this->getRestSchema(),
74
            $this->getDefaultValue(),
75
            $this->getExtraArgs()
76
        );
77
    }
78
79
    public static function for(string $optionName): SettingBuilder
80
    {
81
        return new static($optionName);
82
    }
83
}
84