1 | <?php |
||
20 | class Response |
||
21 | { |
||
22 | const DEFAULT_ENTITY_TYPE = Update::class; |
||
23 | |||
24 | protected $decodedData = []; |
||
25 | |||
26 | protected $lastUpdate = 0; |
||
27 | |||
28 | protected $entities = []; |
||
29 | |||
30 | protected $parent; |
||
31 | |||
32 | /** |
||
33 | * Creates an instanse of Response class from Raw JSON string and builds corresponding entity |
||
34 | * if passed in entity class. This class should be instantiated for every JSON response from Telegram. |
||
35 | * |
||
36 | * @param string $rawData Raw JSON string |
||
37 | * @param null|string $entityClass Entity class that should be instantiated with decoded JSON data |
||
38 | * @param null|AbstractEntity $parent Parent class should be set as parent for newly instantiated entity |
||
39 | */ |
||
40 | public function __construct($rawData, $entityClass = null, $parent = null) |
||
53 | |||
54 | /** |
||
55 | * Returns JSON data decoded as an array. |
||
56 | * |
||
57 | * @param string $rawData JSON string |
||
58 | * |
||
59 | * @return array|mixed |
||
60 | */ |
||
61 | protected function decodeData($rawData) |
||
75 | |||
76 | /** |
||
77 | * Checks whether an error response from Telegram was received. |
||
78 | * |
||
79 | * @return bool |
||
80 | */ |
||
81 | public function isErrorReceived() |
||
89 | |||
90 | /** |
||
91 | * Builds entity objects array from an array of raw entity data. Returns an array with built entities. |
||
92 | * |
||
93 | * @param array $rawData Raw entity data array |
||
94 | * @param null|string $entityClass Entity class |
||
95 | * |
||
96 | * @return array |
||
97 | */ |
||
98 | protected function buildEntities(array $rawData, $entityClass = null) |
||
131 | |||
132 | /** |
||
133 | * Builds desired entity from raw entity's data array. Returns class entity |
||
134 | * |
||
135 | * @param array $rawItemData Array with raw entity's data |
||
136 | * @param null|string $entityClass Entity class to instantiate, if not passed - default Entity class will be used. |
||
137 | * |
||
138 | * @return AbstractEntity |
||
139 | */ |
||
140 | protected function buildEntity(array $rawItemData, $entityClass = null) |
||
154 | |||
155 | /** |
||
156 | * Returns an array with entities |
||
157 | * |
||
158 | * @return array |
||
159 | */ |
||
160 | public function getEntities() |
||
164 | |||
165 | /** |
||
166 | * Returns an entity at certain offset or null if entity does not exists. |
||
167 | * |
||
168 | * @param int $offset Offset |
||
169 | * |
||
170 | * @return mixed|null |
||
171 | */ |
||
172 | public function getEntityByOffset($offset = 0) |
||
176 | |||
177 | /** |
||
178 | * Returns first entity. More meaningful wrapper for self::getEntityByOffset(0) method. |
||
179 | * |
||
180 | * @return mixed|null |
||
181 | */ |
||
182 | public function getFirstEntity() |
||
186 | |||
187 | /** |
||
188 | * Returns raw entities list from decoded JSON data array. |
||
189 | * |
||
190 | * @return array |
||
191 | */ |
||
192 | protected function getRawEntitiesList() |
||
204 | |||
205 | /** |
||
206 | * Returns count of entities. |
||
207 | * |
||
208 | * @return int |
||
209 | */ |
||
210 | public function getEntitiesCount() |
||
214 | |||
215 | /** |
||
216 | * Returns last update id gathered from the last Update entity. |
||
217 | * |
||
218 | * @return int |
||
219 | */ |
||
220 | public function getLastUpdate() |
||
224 | |||
225 | /** |
||
226 | * Returns an offset to skip previous updates in the listener mode. |
||
227 | * |
||
228 | * @return int |
||
229 | */ |
||
230 | public function getOffset() |
||
234 | } |
||
235 |
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..