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 array $attributes |
|
|
|
|
77
|
|
|
*/ |
78
|
|
|
public function addAttribute(Attribute $attribute) |
79
|
|
|
{ |
80
|
|
|
$this->attributes[] = $attribute; |
81
|
|
|
} |
82
|
|
|
|
83
|
|
|
public function setHint($message) |
84
|
|
|
{ |
85
|
|
|
$this->addAttribute(new Attribute(self::HINT_KEY, $message, false)); |
86
|
|
|
} |
87
|
|
|
|
88
|
|
|
/** |
89
|
|
|
* @return mixed |
90
|
|
|
*/ |
91
|
|
|
public function getStatus() |
92
|
|
|
{ |
93
|
|
|
return $this->status; |
94
|
|
|
} |
95
|
|
|
|
96
|
|
|
/** |
97
|
|
|
* @return mixed |
98
|
|
|
*/ |
99
|
|
|
public function getValue() |
100
|
|
|
{ |
101
|
|
|
return $this->value; |
102
|
|
|
} |
103
|
|
|
|
104
|
|
|
/** |
105
|
|
|
* @return string |
106
|
|
|
*/ |
107
|
|
|
public function getTool() |
108
|
|
|
{ |
109
|
|
|
return $this->tool; |
110
|
|
|
} |
111
|
|
|
|
112
|
|
|
/** |
113
|
|
|
* @param string $tool |
114
|
|
|
*/ |
115
|
|
|
public function setTool($tool) |
116
|
|
|
{ |
117
|
|
|
$this->tool = $tool; |
118
|
|
|
} |
119
|
|
|
|
120
|
|
|
/** |
121
|
|
|
* @return string |
122
|
|
|
*/ |
123
|
|
|
public function getIdentifierRule() |
124
|
|
|
{ |
125
|
|
|
return $this->identifierRule; |
126
|
|
|
} |
127
|
|
|
|
128
|
|
|
/** |
129
|
|
|
* @param string $identifier |
|
|
|
|
130
|
|
|
*/ |
131
|
|
|
public function setIdentifierRule($identifierRule) |
132
|
|
|
{ |
133
|
|
|
$this->identifierRule = $identifierRule; |
134
|
|
|
} |
135
|
|
|
|
136
|
|
|
/** |
137
|
|
|
* @return string |
138
|
|
|
*/ |
139
|
|
|
public function getMessage() |
140
|
|
|
{ |
141
|
|
|
return $this->message; |
142
|
|
|
} |
143
|
|
|
|
144
|
|
|
/** |
145
|
|
|
* @param string $message |
146
|
|
|
*/ |
147
|
|
|
public function setMessage($message) |
148
|
|
|
{ |
149
|
|
|
$this->message = $message; |
150
|
|
|
} |
151
|
|
|
|
152
|
|
|
/** |
153
|
|
|
* @return UriAwareResponse |
154
|
|
|
*/ |
155
|
|
|
public function getResponse() |
156
|
|
|
{ |
157
|
|
|
return $this->response; |
158
|
|
|
} |
159
|
|
|
|
160
|
|
|
/** |
161
|
|
|
* @param ResponseInterface $response |
162
|
|
|
*/ |
163
|
|
|
public function setResponse(ResponseInterface $response) |
164
|
|
|
{ |
165
|
|
|
$this->response = $response; |
|
|
|
|
166
|
|
|
} |
167
|
|
|
|
168
|
|
|
/** |
169
|
|
|
* @return mixed |
170
|
|
|
*/ |
171
|
|
|
public function getRuleName() |
172
|
|
|
{ |
173
|
|
|
return $this->ruleName; |
174
|
|
|
} |
175
|
|
|
|
176
|
|
|
/** |
177
|
|
|
* @param mixed $ruleName |
178
|
|
|
*/ |
179
|
|
|
public function setRuleName($ruleName) |
180
|
|
|
{ |
181
|
|
|
$this->ruleName = $ruleName; |
182
|
|
|
} |
183
|
|
|
|
184
|
|
|
/** |
185
|
|
|
* @return string |
186
|
|
|
*/ |
187
|
|
|
public function getUrl() |
188
|
|
|
{ |
189
|
|
|
return $this->url; |
190
|
|
|
} |
191
|
|
|
} |
192
|
|
|
|
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
$ireland
is not defined by the methodfinale(...)
.The most likely cause is that the parameter was changed, but the annotation was not.