Completed
Push — master ( a2df97...e9a9f0 )
by Vladimir
06:27
created

CheckTrait::getImportance()   A

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
eloc 1
dl 0
loc 3
ccs 0
cts 2
cp 0
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 0
crap 2
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
84
85 70
    public function getId(): string
0 ignored issues
show
Coding Style introduced by
Missing doc comment for function getId()
Loading history...
86
    {
87 70
        return $this->id;
88
    }
89
90 135
    public function setId(string $id)
0 ignored issues
show
Coding Style introduced by
Missing doc comment for function setId()
Loading history...
91
    {
92 135
        $this->id = $id;
93 135
    }
94
95
    /**
0 ignored issues
show
Coding Style introduced by
Missing short description in doc comment
Loading history...
96
     * @return mixed
97
     */
98
    public function getImportance()
99
    {
100
        return $this->importance;
101
    }
102
103
    /**
0 ignored issues
show
Coding Style introduced by
Missing short description in doc comment
Loading history...
104
     * @param mixed $importance
0 ignored issues
show
Coding Style introduced by
Missing parameter comment
Loading history...
105
     */
0 ignored issues
show
Coding Style introduced by
Missing @return tag in function comment
Loading history...
106 109
    public function setImportance($importance)
107
    {
108 109
        $this->importance = $importance;
109 109
    }
110
111
    /**
0 ignored issues
show
Coding Style introduced by
Missing short description in doc comment
Loading history...
112
     * @return string[]
113
     */
114 52
    public function getTags(): array
115
    {
116 52
        return $this->tags;
117
    }
118
119
    /**
0 ignored issues
show
Coding Style introduced by
Missing short description in doc comment
Loading history...
120
     * @param string[] $tags
0 ignored issues
show
Coding Style introduced by
Missing parameter comment
Loading history...
121
     */
0 ignored issues
show
Coding Style introduced by
Missing @return tag in function comment
Loading history...
122 114
    public function setTags(array $tags)
123
    {
124 114
        $this->tags = $tags;
125 114
        $this->tags = array_unique($this->tags);
126 114
    }
127
128
    /**
0 ignored issues
show
Coding Style introduced by
Missing short description in doc comment
Loading history...
129
     * @param string $tag
0 ignored issues
show
Coding Style introduced by
Missing parameter comment
Loading history...
130
     */
0 ignored issues
show
Coding Style introduced by
Missing @return tag in function comment
Loading history...
131
    public function addTag($tag)
132
    {
133
        $this->tags[$tag];
134
        $this->tags = array_unique($this->tags);
135
    }
136
137 52
    public function getGroup(): string
0 ignored issues
show
Coding Style introduced by
Missing doc comment for function getGroup()
Loading history...
138
    {
139 52
        return $this->group;
140
    }
141
142 114
    public function setGroup(string $group)
0 ignored issues
show
Coding Style introduced by
Missing doc comment for function setGroup()
Loading history...
143
    {
144 114
        $this->group = $group;
145 114
    }
146
147
    /**
0 ignored issues
show
Coding Style introduced by
Missing short description in doc comment
Loading history...
148
     * @JMS\SerializedName("label")
149
     * @JMS\Type("string")
150
     * @JMS\VirtualProperty()
151
     * @JMS\Expose()
152
     */
0 ignored issues
show
Coding Style introduced by
Missing @return tag in function comment
Loading history...
153 58
    public function getLabel(): string
154
    {
155 58
        if (null !== $this->label) {
156 12
            return $this->label;
157
        }
158
159 53
        return sprintf('Check %s', $this->id);
160
    }
161
162 114
    public function setLabel($label)
0 ignored issues
show
Coding Style introduced by
Missing doc comment for function setLabel()
Loading history...
163
    {
164 114
        $this->label = $label;
165 114
    }
166
167
    /**
0 ignored issues
show
Coding Style introduced by
Missing short description in doc comment
Loading history...
168
     * @return ?string
169
     */
170
    public function getDescr(): ?string
171
    {
172
        return $this->descr;
173
    }
174
175 109
    public function setDescr(?string $descr)
0 ignored issues
show
Coding Style introduced by
Missing doc comment for function setDescr()
Loading history...
176
    {
177 109
        $this->descr = $descr;
178 109
    }
179
180 110
    public function setAdditionParams(array $data)
0 ignored issues
show
Coding Style introduced by
Missing doc comment for function setAdditionParams()
Loading history...
181
    {
182 110
        if (array_key_exists('id', $data)) {
183 110
            $this->setId($data['id']);
184
        }
185
186 110
        if (array_key_exists('group', $data)) {
187 110
            $this->setGroup($data['group']);
188
        }
189
190 110
        if (array_key_exists('importance', $data)) {
191 109
            $this->setImportance($data['importance']);
192
        }
193
194 110
        if (array_key_exists('tags', $data)) {
195 110
            $this->setTags($data['tags']);
196
        }
197
198 110
        if (array_key_exists('label', $data)) {
199 110
            $this->setLabel($data['label']);
200
        }
201
202 110
        if (array_key_exists('descr', $data)) {
203 109
            $this->setDescr($data['descr']);
204
        }
205 110
    }
206
}
207