Completed
Push — master ( 90448b...2ebf44 )
by Vladimir
05:45 queued 30s
created

CheckTrait::check()   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("tags")
56
     * @JMS\SkipWhenEmpty()
57
     * @JMS\Type("array<string>")
58
     * @JMS\Expose()
59
     *
60
     * @var string[]
61
     */
62
    protected $tags = [];
63
64
    /**
65
     * Perform the actual check and return a ResultInterface.
66
     *
67
     * @return ResultInterface
68
     */
69
    abstract public function check();
70
71 62
    public function getId(): string
0 ignored issues
show
Coding Style introduced by
Missing doc comment for function getId()
Loading history...
72
    {
73 62
        return $this->id;
74
    }
75
76 123
    public function setId(string $id): self
0 ignored issues
show
Coding Style introduced by
Missing doc comment for function setId()
Loading history...
77
    {
78 123
        $this->id = $id;
79
80 123
        return $this;
81
    }
82
83
    /**
0 ignored issues
show
Coding Style introduced by
Missing short description in doc comment
Loading history...
84
     * @return string[]
85
     */
86 51
    public function getTags(): array
87
    {
88 51
        return $this->tags;
89
    }
90
91
    /**
0 ignored issues
show
Coding Style introduced by
Missing short description in doc comment
Loading history...
92
     * @param string[] $tags
0 ignored issues
show
Coding Style introduced by
Missing parameter comment
Loading history...
93
     */
0 ignored issues
show
Coding Style introduced by
Missing @return tag in function comment
Loading history...
94 102
    public function setTags(array $tags): self
95
    {
96 102
        $this->tags = $tags;
97
98 102
        return $this;
99
    }
100
101 51
    public function getGroup(): string
0 ignored issues
show
Coding Style introduced by
Missing doc comment for function getGroup()
Loading history...
102
    {
103 51
        return $this->group;
104
    }
105
106 102
    public function setGroup(string $group): self
0 ignored issues
show
Coding Style introduced by
Missing doc comment for function setGroup()
Loading history...
107
    {
108 102
        $this->group = $group;
109
110 102
        return $this;
111
    }
112
113
    /**
0 ignored issues
show
Coding Style introduced by
Missing short description in doc comment
Loading history...
114
     * @JMS\SerializedName("label")
115
     * @JMS\Type("string")
116
     * @JMS\VirtualProperty()
117
     * @JMS\Expose()
118
     */
0 ignored issues
show
Coding Style introduced by
Missing @return tag in function comment
Loading history...
119 48
    public function getLabel(): string
120
    {
121 48
        if (null !== $this->label) {
122 9
            return $this->label;
123
        }
124
125 43
        return sprintf('Check %s', $this->id);
126
    }
127
128 102
    public function setLabel($label): self
0 ignored issues
show
Coding Style introduced by
Missing doc comment for function setLabel()
Loading history...
129
    {
130 102
        $this->label = $label;
131
132 102
        return $this;
133
    }
134
135
    /**
0 ignored issues
show
Coding Style introduced by
Missing short description in doc comment
Loading history...
136
     * @return ?string
137
     */
138
    public function getDescr(): ?string
139
    {
140
        return $this->descr;
141
    }
142
143 97
    public function setDescr(?string $descr): self
0 ignored issues
show
Coding Style introduced by
Missing doc comment for function setDescr()
Loading history...
144
    {
145 97
        $this->descr = $descr;
146
147 97
        return $this;
148
    }
149
150 98
    public function setAdditionParams(array $data): self
0 ignored issues
show
Coding Style introduced by
Missing doc comment for function setAdditionParams()
Loading history...
151
    {
152 98
        if (array_key_exists('id', $data)) {
153 98
            $this->setId($data['id']);
154
        }
155
156 98
        if (array_key_exists('group', $data)) {
157 98
            $this->setGroup($data['group']);
158
        }
159
160 98
        if (array_key_exists('tags', $data)) {
161 98
            $this->setTags($data['tags']);
162
        }
163
164 98
        if (array_key_exists('label', $data)) {
165 98
            $this->setLabel($data['label']);
166
        }
167
168 98
        if (array_key_exists('descr', $data)) {
169 97
            $this->setDescr($data['descr']);
170
        }
171
172 98
        return $this;
173
    }
174
}
175