Completed
Pull Request — master (#210)
by Дмитрий
13:24
created

Issue::getCheckName()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 2
c 0
b 0
f 0
nc 1
nop 0
dl 0
loc 4
rs 10
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 string
105
     */
106
    protected $location;
107
108
    /**
109
     * @param string $checkName
110
     * @param string $description
111
     * @param array $location
112
     * @param array $categories
113
     */
114
    public function __construct($checkName, $description, array $location, array $categories = [self::CATEGORY_BUG_RISK])
115
    {
116
        $this->checkName = $checkName;
117
        $this->description = $description;
118
        $this->location = $location;
0 ignored issues
show
Documentation Bug introduced by
It seems like $location of type array is incompatible with the declared type string of property $location.

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...
119
        $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...
120
    }
121
122
    public function toArray()
123
    {
124
        return [
125
            'type' => $this->type,
126
            'description' => $this->description,
127
            'location' => $this->location,
128
            'categories' => $this->categories,
129
        ];
130
    }
131
132
    /**
133
     * @return string
134
     */
135
    public function getLocation()
136
    {
137
        return $this->location;
138
    }
139
140
    /**
141
     * @return string
142
     */
143
    public function getType()
144
    {
145
        return $this->type;
146
    }
147
148
    /**
149
     * @return string
150
     */
151
    public function getCheckName()
152
    {
153
        return $this->checkName;
154
    }
155
156
    /**
157
     * @return string
158
     */
159
    public function getDescription()
160
    {
161
        return $this->description;
162
    }
163
}
164