Passed
Push — master ( 1cbff4...e83acc )
by
02:22
created

SettingSchema::getSectionName()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 0
Metric Value
dl 0
loc 4
ccs 0
cts 2
cp 0
rs 10
c 0
b 0
f 0
cc 1
eloc 2
nc 1
nop 0
crap 2
1
<?php
2
3
/*
4
 * This file is part of the PhpMob package.
5
 *
6
 * (c) Ishmael Doss <[email protected]>
7
 *
8
 * For the full copyright and license information, please view the LICENSE
9
 * file that was distributed with this source code.
10
 */
11
12
declare(strict_types=1);
13
14
namespace PhpMob\Settings\Schema;
15
16
/**
17
 * @author Ishmael Doss <[email protected]>
18
 */
19
class SettingSchema implements \JsonSerializable
20
{
21
    /**
22
     * @var array
23
     */
24
    private $data = [];
25
26
    /**
27
     * @var Section
28
     */
29
    private $section;
30
31 9
    public function __construct(Section $section, $key, array $schema)
32
    {
33 9
        $this->section = $section;
34 9
        $this->data['section'] = $section->getName();
0 ignored issues
show
Bug introduced by
Consider using $section->name. There is an issue with getName() and APC-enabled PHP versions.
Loading history...
35 9
        $this->data['key'] = $key;
36
37 9
        foreach ($schema as $key => $value) {
38 9
            $this->data[$key] = 'blueprint' === $key ? new Blueprint($value) : $value;
39
        }
40 9
    }
41
42
    /**
43
     * @return bool
44
     */
45
    public function isEnabled()
46
    {
47
        return $this->data['enabled'];
48
    }
49
50
    /**
51
     * @return string
52
     */
53
    public function getLabel()
54
    {
55
        return $this->data['label'];
56
    }
57
58
    /**
59
     * @return string
60
     */
61
    public function getDescription()
62
    {
63
        return $this->data['description'];
64
    }
65
66
    /**
67
     * @return string
68
     */
69 4
    public function getKey()
70
    {
71 4
        return $this->data['key'];
72
    }
73
74
    /**
75
     * @return string
76
     */
77 3
    public function getValue()
78
    {
79 3
        return (string) $this->data['value'];
80
    }
81
82
    /**
83
     * @return string
84
     */
85
    public function getType()
86
    {
87
        return $this->data['type'];
88
    }
89
90
    /**
91
     * @return string
92
     */
93
    public function getSectionName()
94
    {
95
        return $this->data['section'];
96
    }
97
98
    /**
99
     * @return Blueprint
100
     */
101
    public function getBlueprint()
102
    {
103
        return $this->data['blueprint'];
104
    }
105
106
    /**
107
     * @return Section
108
     */
109 3
    public function getSection()
110
    {
111 3
        return $this->section;
112
    }
113
114
    /**
115
     * {@inheritdoc}
116
     */
117
    public function jsonSerialize()
118
    {
119
        return $this->data;
120
    }
121
}
122