Completed
Push — master ( 4685bb...c1e464 )
by Дмитрий
03:28
created

Issue::__construct()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 7
Code Lines 5

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 6
CRAP Score 1

Importance

Changes 0
Metric Value
cc 1
eloc 5
nc 1
nop 4
dl 0
loc 7
ccs 6
cts 6
cp 1
crap 1
rs 9.4285
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 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 34
    public function __construct($checkName, $description, array $location, array $categories = [self::CATEGORY_BUG_RISK])
115
    {
116 34
        $this->checkName = $checkName;
117 34
        $this->description = $description;
118 34
        $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 34
        $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 34
    }
121
122
    /**
123
     * @return array
124
     */
125
    public function toArray()
126
    {
127
        return [
128
            'type' => $this->type,
129
            'check_name' => $this->checkName,
130
            'description' => $this->description,
131
            'location' => $this->location,
132
            'categories' => $this->categories,
133
        ];
134
    }
135
136
    /**
137
     * @return string
138
     */
139 34
    public function getLocation()
140
    {
141 34
        return $this->location;
142
    }
143
144
    /**
145
     * @return string
146
     */
147
    public function getType()
148
    {
149
        return $this->type;
150
    }
151
152
    /**
153
     * @return string
154
     */
155 34
    public function getCheckName()
156
    {
157 34
        return $this->checkName;
158
    }
159
160
    /**
161
     * @return string
162
     */
163 34
    public function getDescription()
164
    {
165 34
        return $this->description;
166
    }
167
}
168