1 | <?php |
||
29 | class Reasoning implements ArrayAccess, JsonSerializable |
||
30 | { |
||
31 | /** |
||
32 | * The reason this reasoning maps to |
||
33 | * |
||
34 | * This may be an arbitrary scalar but is most likely to map to a known constant in `RequirementReason`. |
||
35 | * |
||
36 | * @var int|string |
||
37 | * @see RequirementReason Possible mapping target |
||
38 | */ |
||
39 | private $reasonId; |
||
40 | /** |
||
41 | * @var int |
||
42 | */ |
||
43 | private $line; |
||
44 | /** |
||
45 | * @var null|string |
||
46 | */ |
||
47 | private $msg; |
||
48 | /** |
||
49 | * @var \Pvra\AnalysisResult |
||
50 | */ |
||
51 | private $result; |
||
52 | /** |
||
53 | * @var array |
||
54 | */ |
||
55 | private $data; |
||
56 | /** |
||
57 | * @var string|false |
||
58 | */ |
||
59 | private $version; |
||
60 | |||
61 | /** |
||
62 | * RequirementReasoning constructor |
||
63 | * |
||
64 | * Used to construct this reasoning. Only the `reasonId`, `line` and `result` parameters |
||
65 | * are required. The remaining parameters can be determined based on the reasonId and result instance. * |
||
66 | * |
||
67 | * @param int|string $reasonId The mapped reasonId |
||
68 | * @param int $line The mapped line |
||
69 | * @param \Pvra\AnalysisResult $result The result this reasoning applies to |
||
70 | * @param string|null $version The required version. |
||
71 | * @param null|string $msg The message related to this reasoning. If this parameter is set to `null` the message is |
||
72 | * fetched from the `MessageLocator` attached to the result instance related to this instance. |
||
73 | * @param array $data An array of additional data passed to the `MessageFormatter` |
||
74 | */ |
||
75 | 174 | public function __construct( |
|
94 | |||
95 | /** |
||
96 | * Array representation of this object |
||
97 | * |
||
98 | * This method creates an array representation of this object including all keys that would be |
||
99 | * available through offsetGet. |
||
100 | * |
||
101 | * @return array |
||
102 | */ |
||
103 | 10 | public function toArray() |
|
116 | |||
117 | /** |
||
118 | * Get the data this instance represents in a format understood by json_encode. |
||
119 | * |
||
120 | * @return array Data to be encoded as json |
||
121 | */ |
||
122 | 2 | public function jsonSerialize() |
|
126 | |||
127 | |||
128 | /** |
||
129 | * Get the related result |
||
130 | * |
||
131 | * @return \Pvra\AnalysisResult |
||
132 | */ |
||
133 | 50 | protected function getResult() |
|
137 | |||
138 | /** |
||
139 | * @param string $name |
||
140 | * @return array|int|null|string |
||
141 | */ |
||
142 | 20 | public function get($name) |
|
152 | |||
153 | /** |
||
154 | * @param int|string $offset |
||
155 | * @return bool |
||
156 | */ |
||
157 | 24 | public function offsetExists($offset) |
|
161 | |||
162 | /** |
||
163 | * @param mixed $offset |
||
164 | * @return array|int|null|string |
||
165 | */ |
||
166 | 136 | public function offsetGet($offset) |
|
202 | |||
203 | /** |
||
204 | * @param mixed $offset |
||
205 | * @param mixed $value |
||
206 | * @throws \Exception |
||
207 | */ |
||
208 | 2 | public function offsetSet($offset, $value) |
|
212 | |||
213 | /** |
||
214 | * @param mixed $offset |
||
215 | * @throws \Exception |
||
216 | */ |
||
217 | 2 | public function offsetUnset($offset) |
|
221 | } |
||
222 |