Test Failed
Push — master ( 135f34...8b25c6 )
by Chris
33:49
created

SettingBuilder::extra()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
eloc 1
dl 0
loc 3
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 1
1
<?php
2
3
namespace Leonidas\Library\System\Setting;
4
5
use Leonidas\Contracts\System\Setting\SettingBuilderInterface;
6
use Leonidas\Contracts\System\Setting\SettingHandlerInterface;
7
use Leonidas\Library\System\Setting\Traits\HasSettingDataTrait;
8
9
class SettingBuilder implements SettingBuilderInterface
10
{
11
    use HasSettingDataTrait;
12
13
    protected ?SettingHandlerInterface $handler = null;
14
15
    public function __construct(string $optionName)
16
    {
17
        $this->optionName = $optionName;
18
    }
19
20
    public function optionGroup(string $optionGroup)
21
    {
22
        $this->optionGroup = $optionGroup;
23
    }
24
25
    public function optionName(string $optionName)
26
    {
27
        $this->optionName = $optionName;
28
    }
29
30
    public function type(?string $type)
31
    {
32
        $this->type = $type;
33
    }
34
35
    public function description(?string $description)
36
    {
37
        $this->description = $description;
38
    }
39
40
    public function schema($schema)
41
    {
42
        $this->restSchema = $schema;
43
    }
44
45
    public function default($default)
46
    {
47
        $this->defaultValue = $default;
48
    }
49
50
    public function extra(?array $extraArgs)
51
    {
52
        $this->extraArgs = $extraArgs;
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