Completed
Push — master ( e9a9f0...13c004 )
by Vladimir
06:49
created

CheckTrait::getImportance()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 1

Importance

Changes 0
Metric Value
eloc 1
dl 0
loc 3
ccs 2
cts 2
cp 1
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 0
crap 1
1
<?php
2
3
/**
4
 * This file is part of the `tvi/monitor-bundle` project.
5
 *
6
 * (c) https://github.com/turnaev/monitor-bundle/graphs/contributors
7
 *
8
 * For the full copyright and license information, please view the LICENSE.md
9
 * file that was distributed with this source code.
10
 */
0 ignored issues
show
Coding Style introduced by
PHP version not specified
Loading history...
Coding Style introduced by
Missing @category tag in file comment
Loading history...
Coding Style introduced by
Missing @package tag in file comment
Loading history...
Coding Style introduced by
Missing @author tag in file comment
Loading history...
Coding Style introduced by
Missing @license tag in file comment
Loading history...
Coding Style introduced by
Missing @link tag in file comment
Loading history...
11
12
namespace Tvi\MonitorBundle\Check;
13
14
use JMS\Serializer\Annotation as JMS;
15
use ZendDiagnostics\Result\ResultInterface;
16
17
/**
0 ignored issues
show
Coding Style introduced by
Missing short description in doc comment
Loading history...
18
 * @author Vladimir Turnaev <[email protected]>
19
 */
0 ignored issues
show
Coding Style introduced by
Missing @category tag in class comment
Loading history...
Coding Style introduced by
Missing @package tag in class comment
Loading history...
Coding Style introduced by
Missing @license tag in class comment
Loading history...
Coding Style introduced by
Missing @link tag in class comment
Loading history...
20
trait CheckTrait
21
{
22
    /**
0 ignored issues
show
Coding Style introduced by
Missing short description in doc comment
Loading history...
23
     * @JMS\SerializedName("id")
24
     * @JMS\Expose()
25
     *
26
     * @var string
27
     */
28
    protected $id;
29
30
    /**
0 ignored issues
show
Coding Style introduced by
Missing short description in doc comment
Loading history...
31
     * @var ?string
32
     */
33
    protected $label;
34
35
    /**
0 ignored issues
show
Coding Style introduced by
Missing short description in doc comment
Loading history...
36
     * @JMS\SerializedName("group")
37
     * @JMS\Type("string")
38
     * @JMS\Expose()
39
     *
40
     * @var string
41
     */
42
    protected $group;
43
44
    /**
0 ignored issues
show
Coding Style introduced by
Missing short description in doc comment
Loading history...
45
     * @JMS\SerializedName("descr")
46
     * @JMS\Type("string")
47
     * @JMS\SkipWhenEmpty()
48
     * @JMS\Expose()
49
     *
50
     * @var string?
0 ignored issues
show
Documentation Bug introduced by
The doc comment string? at position 0 could not be parsed: Unknown type name 'string?' at position 0 in string?.
Loading history...
51
     */
52
    protected $descr;
53
54
    /**
0 ignored issues
show
Coding Style introduced by
Missing short description in doc comment
Loading history...
55
     * @JMS\SerializedName("importance")
56
     * @JMS\SkipWhenEmpty()
57
     * @JMS\Type("string")
58
     * @JMS\Expose()
59
     *
60
     * @var ?string
61
     */
62
    protected $importance;
63
64
65
66
    /**
0 ignored issues
show
Coding Style introduced by
Missing short description in doc comment
Loading history...
67
     * @JMS\SerializedName("tags")
68
     * @JMS\SkipWhenEmpty()
69
     * @JMS\Type("array<string>")
70
     * @JMS\Expose()
71
     *
72
     * @var string[]
73
     */
74
    protected $tags = [];
75
76
    /**
77
     * Perform the actual check and return a ResultInterface.
78
     *
79
     * @return ResultInterface
80
     */
81
    abstract public function check();
82
83 71
    public function getId(): string
0 ignored issues
show
Coding Style introduced by
Missing doc comment for function getId()
Loading history...
84
    {
85 71
        return $this->id;
86
    }
87
88 136
    public function setId(string $id)
0 ignored issues
show
Coding Style introduced by
Missing doc comment for function setId()
Loading history...
89
    {
90 136
        $this->id = $id;
91 136
    }
92
93
94 47
    public function getImportance()
0 ignored issues
show
Coding Style introduced by
Missing doc comment for function getImportance()
Loading history...
95
    {
96 47
        return $this->importance;
97
    }
98
99
100 110
    public function setImportance($importance)
0 ignored issues
show
Coding Style introduced by
Missing doc comment for function setImportance()
Loading history...
101
    {
102 110
        $this->importance = $importance;
103 110
    }
104
105
    /**
0 ignored issues
show
Coding Style introduced by
Missing short description in doc comment
Loading history...
106
     * @return string[]
107
     */
108 53
    public function getTags(): array
109
    {
110 53
        return $this->tags;
111
    }
112
113
    /**
0 ignored issues
show
Coding Style introduced by
Missing short description in doc comment
Loading history...
114
     * @param string[] $tags
0 ignored issues
show
Coding Style introduced by
Missing parameter comment
Loading history...
115
     */
0 ignored issues
show
Coding Style introduced by
Missing @return tag in function comment
Loading history...
116 115
    public function setTags(array $tags)
117
    {
118 115
        $this->tags = $tags;
119 115
        $this->tags = array_unique($this->tags);
120 115
    }
121
122
    /**
0 ignored issues
show
Coding Style introduced by
Missing short description in doc comment
Loading history...
123
     * @param string $tag
0 ignored issues
show
Coding Style introduced by
Missing parameter comment
Loading history...
124
     */
0 ignored issues
show
Coding Style introduced by
Missing @return tag in function comment
Loading history...
125
    public function addTag($tag)
126
    {
127
        $this->tags[$tag];
128
        $this->tags = array_unique($this->tags);
129
    }
130
131 53
    public function getGroup(): string
0 ignored issues
show
Coding Style introduced by
Missing doc comment for function getGroup()
Loading history...
132
    {
133 53
        return $this->group;
134
    }
135
136 115
    public function setGroup(string $group)
0 ignored issues
show
Coding Style introduced by
Missing doc comment for function setGroup()
Loading history...
137
    {
138 115
        $this->group = $group;
139 115
    }
140
141
    /**
0 ignored issues
show
Coding Style introduced by
Missing short description in doc comment
Loading history...
142
     * @JMS\SerializedName("label")
143
     * @JMS\Type("string")
144
     * @JMS\VirtualProperty()
145
     * @JMS\Expose()
146
     */
0 ignored issues
show
Coding Style introduced by
Missing @return tag in function comment
Loading history...
147 59
    public function getLabel(): string
148
    {
149 59
        if (null !== $this->label) {
150 13
            return $this->label;
151
        }
152
153 54
        return sprintf('Check %s', $this->id);
154
    }
155
156 115
    public function setLabel($label)
0 ignored issues
show
Coding Style introduced by
Missing doc comment for function setLabel()
Loading history...
157
    {
158 115
        $this->label = $label;
159 115
    }
160
161
    /**
0 ignored issues
show
Coding Style introduced by
Missing short description in doc comment
Loading history...
162
     * @return ?string
163
     */
164
    public function getDescr(): ?string
165
    {
166
        return $this->descr;
167
    }
168
169 110
    public function setDescr(?string $descr)
0 ignored issues
show
Coding Style introduced by
Missing doc comment for function setDescr()
Loading history...
170
    {
171 110
        $this->descr = $descr;
172 110
    }
173
174 111
    public function setAdditionParams(array $data)
0 ignored issues
show
Coding Style introduced by
Missing doc comment for function setAdditionParams()
Loading history...
175
    {
176 111
        if (array_key_exists('id', $data)) {
177 111
            $this->setId($data['id']);
178
        }
179
180 111
        if (array_key_exists('group', $data)) {
181 111
            $this->setGroup($data['group']);
182
        }
183
184 111
        if (array_key_exists('importance', $data)) {
185 110
            $this->setImportance($data['importance']);
186
        }
187
188 111
        if (array_key_exists('tags', $data)) {
189 111
            $this->setTags($data['tags']);
190
        }
191
192 111
        if (array_key_exists('label', $data)) {
193 111
            $this->setLabel($data['label']);
194
        }
195
196 111
        if (array_key_exists('descr', $data)) {
197 110
            $this->setDescr($data['descr']);
198
        }
199 111
    }
200
}
201