|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
namespace whm\Smoke\Rules; |
|
4
|
|
|
|
|
5
|
|
|
use phm\HttpWebdriverClient\Http\Response\UriAwareResponse; |
|
6
|
|
|
use Psr\Http\Message\ResponseInterface; |
|
7
|
|
|
|
|
8
|
|
|
class CheckResult |
|
9
|
|
|
{ |
|
10
|
|
|
const STATUS_SUCCESS = 'success'; |
|
11
|
|
|
const STATUS_FAILURE = 'failure'; |
|
12
|
|
|
const STATUS_SKIPPED = 'skipped'; |
|
13
|
|
|
const STATUS_NONE = 'none'; |
|
14
|
|
|
|
|
15
|
|
|
const HINT_KEY = '__hint'; |
|
16
|
|
|
|
|
17
|
|
|
const IDENTIFIER_RULE_STANDARD = 'standard'; |
|
18
|
|
|
const IDENTIFIER_RULE_WITHOUT_SMOKE_PREFIX = 'withoutSmokePrefix'; |
|
19
|
|
|
|
|
20
|
|
|
private $status; |
|
21
|
|
|
private $value; |
|
22
|
|
|
private $message; |
|
23
|
|
|
|
|
24
|
|
|
/** |
|
25
|
|
|
* @var Attribute[] |
|
26
|
|
|
*/ |
|
27
|
|
|
private $attributes = array(); |
|
28
|
|
|
private $ruleName; |
|
29
|
|
|
private $url; |
|
30
|
|
|
|
|
31
|
|
|
private $tool; |
|
32
|
|
|
private $identifierRule = self::IDENTIFIER_RULE_STANDARD; |
|
33
|
|
|
|
|
34
|
|
|
/** |
|
35
|
|
|
* @var UriAwareResponse |
|
36
|
|
|
*/ |
|
37
|
|
|
private $response; |
|
38
|
|
|
|
|
39
|
|
|
/** |
|
40
|
|
|
* Result constructor. |
|
41
|
|
|
* |
|
42
|
|
|
* @param $status |
|
43
|
|
|
* @param $value |
|
44
|
|
|
* @param $message |
|
45
|
|
|
*/ |
|
46
|
|
|
public function __construct($status, $message = '', $value = null, $url = null) |
|
47
|
|
|
{ |
|
48
|
|
|
$this->status = $status; |
|
49
|
|
|
$this->value = $value; |
|
50
|
|
|
$this->message = $message; |
|
51
|
|
|
$this->url = $url; |
|
52
|
|
|
} |
|
53
|
|
|
|
|
54
|
|
|
/** |
|
55
|
|
|
* @return Attribute[] |
|
56
|
|
|
*/ |
|
57
|
|
|
public function getAttributes() |
|
58
|
|
|
{ |
|
59
|
|
|
return $this->attributes; |
|
60
|
|
|
} |
|
61
|
|
|
|
|
62
|
|
|
/** |
|
63
|
|
|
* @return boolean |
|
64
|
|
|
*/ |
|
65
|
|
|
public function hasAttribute($key) |
|
66
|
|
|
{ |
|
67
|
|
|
foreach ($this->attributes as $attribute) { |
|
68
|
|
|
if ($attribute->getKey() == $key) { |
|
69
|
|
|
return true; |
|
70
|
|
|
} |
|
71
|
|
|
} |
|
72
|
|
|
return false; |
|
73
|
|
|
} |
|
74
|
|
|
|
|
75
|
|
|
/** |
|
76
|
|
|
* @param Attribute $attributes |
|
|
|
|
|
|
77
|
|
|
*/ |
|
78
|
|
|
public function addAttribute(Attribute $attribute) |
|
79
|
|
|
{ |
|
80
|
|
|
$this->attributes[] = $attribute; |
|
81
|
|
|
} |
|
82
|
|
|
|
|
83
|
|
|
/** |
|
84
|
|
|
* @param Attribute[] $attributes |
|
85
|
|
|
*/ |
|
86
|
|
|
public function addAttributes($attributes) |
|
87
|
|
|
{ |
|
88
|
|
|
foreach ($attributes as $attribute) { |
|
89
|
|
|
$this->addAttribute($attribute); |
|
90
|
|
|
} |
|
91
|
|
|
} |
|
92
|
|
|
|
|
93
|
|
|
public function setHint($message) |
|
94
|
|
|
{ |
|
95
|
|
|
$this->addAttribute(new Attribute(self::HINT_KEY, $message, false)); |
|
96
|
|
|
} |
|
97
|
|
|
|
|
98
|
|
|
/** |
|
99
|
|
|
* @return mixed |
|
100
|
|
|
*/ |
|
101
|
|
|
public function getStatus() |
|
102
|
|
|
{ |
|
103
|
|
|
return $this->status; |
|
104
|
|
|
} |
|
105
|
|
|
|
|
106
|
|
|
/** |
|
107
|
|
|
* @return mixed |
|
108
|
|
|
*/ |
|
109
|
|
|
public function getValue() |
|
110
|
|
|
{ |
|
111
|
|
|
return $this->value; |
|
112
|
|
|
} |
|
113
|
|
|
|
|
114
|
|
|
/** |
|
115
|
|
|
* @return string |
|
116
|
|
|
*/ |
|
117
|
|
|
public function getTool() |
|
118
|
|
|
{ |
|
119
|
|
|
return $this->tool; |
|
120
|
|
|
} |
|
121
|
|
|
|
|
122
|
|
|
/** |
|
123
|
|
|
* @param string $tool |
|
124
|
|
|
*/ |
|
125
|
|
|
public function setTool($tool) |
|
126
|
|
|
{ |
|
127
|
|
|
$this->tool = $tool; |
|
128
|
|
|
} |
|
129
|
|
|
|
|
130
|
|
|
/** |
|
131
|
|
|
* @return string |
|
132
|
|
|
*/ |
|
133
|
|
|
public function getIdentifierRule() |
|
134
|
|
|
{ |
|
135
|
|
|
return $this->identifierRule; |
|
136
|
|
|
} |
|
137
|
|
|
|
|
138
|
|
|
/** |
|
139
|
|
|
* @param string $identifier |
|
|
|
|
|
|
140
|
|
|
*/ |
|
141
|
|
|
public function setIdentifierRule($identifierRule) |
|
142
|
|
|
{ |
|
143
|
|
|
$this->identifierRule = $identifierRule; |
|
144
|
|
|
} |
|
145
|
|
|
|
|
146
|
|
|
/** |
|
147
|
|
|
* @return string |
|
148
|
|
|
*/ |
|
149
|
|
|
public function getMessage() |
|
150
|
|
|
{ |
|
151
|
|
|
return $this->message; |
|
152
|
|
|
} |
|
153
|
|
|
|
|
154
|
|
|
/** |
|
155
|
|
|
* @param string $message |
|
156
|
|
|
*/ |
|
157
|
|
|
public function setMessage($message) |
|
158
|
|
|
{ |
|
159
|
|
|
$this->message = $message; |
|
160
|
|
|
} |
|
161
|
|
|
|
|
162
|
|
|
/** |
|
163
|
|
|
* @return UriAwareResponse |
|
164
|
|
|
*/ |
|
165
|
|
|
public function getResponse() |
|
166
|
|
|
{ |
|
167
|
|
|
return $this->response; |
|
168
|
|
|
} |
|
169
|
|
|
|
|
170
|
|
|
/** |
|
171
|
|
|
* @param ResponseInterface $response |
|
172
|
|
|
*/ |
|
173
|
|
|
public function setResponse(ResponseInterface $response) |
|
174
|
|
|
{ |
|
175
|
|
|
$this->response = $response; |
|
|
|
|
|
|
176
|
|
|
} |
|
177
|
|
|
|
|
178
|
|
|
/** |
|
179
|
|
|
* @return mixed |
|
180
|
|
|
*/ |
|
181
|
|
|
public function getRuleName() |
|
182
|
|
|
{ |
|
183
|
|
|
return $this->ruleName; |
|
184
|
|
|
} |
|
185
|
|
|
|
|
186
|
|
|
/** |
|
187
|
|
|
* @param mixed $ruleName |
|
188
|
|
|
*/ |
|
189
|
|
|
public function setRuleName($ruleName) |
|
190
|
|
|
{ |
|
191
|
|
|
$this->ruleName = $ruleName; |
|
192
|
|
|
} |
|
193
|
|
|
|
|
194
|
|
|
/** |
|
195
|
|
|
* @return string |
|
196
|
|
|
*/ |
|
197
|
|
|
public function getUrl() |
|
198
|
|
|
{ |
|
199
|
|
|
return $this->url; |
|
200
|
|
|
} |
|
201
|
|
|
} |
|
202
|
|
|
|
This check looks for PHPDoc comments describing methods or function parameters that do not exist on the corresponding method or function. It has, however, found a similar but not annotated parameter which might be a good fit.
Consider the following example. The parameter
$irelandis not defined by the methodfinale(...).The most likely cause is that the parameter was changed, but the annotation was not.