Completed
Pull Request — master (#235)
by Kévin
03:13
created

Issue::getBlame()   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
cc 1
eloc 2
nc 1
nop 0
dl 0
loc 4
ccs 0
cts 0
cp 0
crap 2
rs 10
c 0
b 0
f 0
1
<?php
2
/**
3
 * @author Patsura Dmitry https://github.com/ovr <[email protected]>
4
 */
5
6
namespace PHPSA;
7
8
class Issue
9
{
10
    /**
11
     * @todo Description
12
     *
13
     * @var string
14
     */
15
    const CATEGORY_BUG_RISK = 'Bug Risk';
16
17
    /**
18
     * @todo Description
19
     *
20
     * @var string
21
     */
22
    const CATEGORY_CLARITY = 'Clarity';
23
24
    /**
25
     * @todo Description
26
     *
27
     * @var string
28
     */
29
    const CATEGORY_COMPATIBILITY = 'Compatibility';
30
31
    /**
32
     * @todo Description
33
     *
34
     * @var string
35
     */
36
    const CATEGORY_COMPLEXITY = 'Complexity';
37
38
    /**
39
     * @todo Description
40
     *
41
     * @var string
42
     */
43
    const CATEGORY_DUPLICATION = 'Duplication';
44
45
    /**
46
     * @todo Description
47
     *
48
     * @var string
49
     */
50
    const CATEGORY_PERFORMANCE = 'Performance';
51
52
    /**
53
     * @todo Description
54
     *
55
     * @var string
56
     */
57
    const CATEGORY_SECURITY = 'Security';
58
59
    /**
60
     * @todo Description
61
     *
62
     * @var string
63
     */
64
    const CATEGORY_STYLE = 'Style';
65
66
    /**
67
     * Required. Must always be "issue".
68
     *
69
     * @var string
70
     */
71
    protected $type = 'issue';
72
73
    /**
74
     * Required. A unique name representing the static analysis check that emitted this issue.
75
     *
76
     * @var string
77
     */
78
    protected $checkName;
79
80
    /**
81
     * Required. A string explaining the issue that was detected.
82
     *
83
     * @var string
84
     */
85
    protected $description;
86
87
    /**
88
     * Optional. A markdown snippet describing the issue, including deeper explanations and links to other resources.
89
     *
90
     * @var string
91
     */
92
    protected $content;
93
94
    /**
95
     * Required. At least one category indicating the nature of the issue being reported.
96
     *
97
     * @var string
98
     */
99
    protected $categories;
100
101
    /**
102
     * Required. A Location object representing the place in the source code where the issue was discovered.
103
     *
104
     * @var IssueLocation
105
     */
106
    protected $location;
107
108
    protected $blame;
109
110
    /**
111
     * @param string $checkName
112
     * @param string $description
113
     * @param IssueLocation $location
114 41
     * @param array $categories
115
     */
116 41
    public function __construct($checkName, $description, IssueLocation $location, array $categories = [self::CATEGORY_BUG_RISK])
117 41
    {
118 41
        $this->checkName = $checkName;
119 41
        $this->description = $description;
120 41
        $this->location = $location;
121
        $this->categories = $categories;
0 ignored issues
show
Documentation Bug introduced by
It seems like $categories of type array is incompatible with the declared type string of property $categories.

Our type inference engine has found an assignment to a property that is incompatible with the declared type of that property.

Either this assignment is in error or the assigned type should be added to the documentation/type hint for that property..

Loading history...
122
    }
123
124
    /**
125
     * @return array
126
     */
127
    public function toArray()
128
    {
129
        return [
130
            'type' => $this->type,
131
            'check_name' => $this->checkName,
132
            'description' => $this->description,
133
            'location' => $this->location->toArray(),
134
            'categories' => $this->categories,
135
            'blame' => $this->blame,
136
        ];
137
    }
138
139 41
    /**
140
     * @return IssueLocation
141 41
     */
142
    public function getLocation()
143
    {
144
        return $this->location;
145
    }
146
147
    /**
148
     * @return string
149
     */
150
    public function getType()
151
    {
152
        return $this->type;
153
    }
154
155 41
    /**
156
     * @return string
157 41
     */
158
    public function getCheckName()
159
    {
160
        return $this->checkName;
161
    }
162
163 41
    /**
164
     * @return string
165 41
     */
166
    public function getDescription()
167
    {
168
        return $this->description;
169
    }
170
171
    /**
172
     * @return string
173
     */
174
    public function getBlame()
175
    {
176
        return $this->blame;
177
    }
178
179
    /**
180
     * @param string $blame
181
     */
182
    public function setBlame($blame)
183
    {
184
        $this->blame = $blame;
185
    }
186
}
187