1 | <?php |
||
9 | class TelegramRawData |
||
10 | { |
||
11 | /** |
||
12 | * Nothing is done so far with this, but it's always a good idea to have the original around |
||
13 | * @var string |
||
14 | */ |
||
15 | private $rawData = ''; |
||
16 | |||
17 | /** |
||
18 | * The actual representation of the decoded data |
||
19 | * @var array |
||
20 | */ |
||
21 | private $decodedData = []; |
||
22 | |||
23 | 36 | public function __construct(string $rawData) |
|
28 | |||
29 | /** |
||
30 | * To quickly find out what type of request we are dealing with |
||
31 | * |
||
32 | * Unused so far |
||
33 | * |
||
34 | * @return string |
||
35 | * @throws InvalidResultType |
||
36 | */ |
||
37 | 8 | public function getTypeOfResult(): string |
|
50 | |||
51 | /** |
||
52 | * Most of the requests Telegram sends, come as an array, so send the response back as an array by default |
||
53 | * |
||
54 | * @return array |
||
55 | */ |
||
56 | 22 | public function getResult(): array |
|
60 | |||
61 | /** |
||
62 | * Hack: for some requests Telegram sends back an array, integer, string or a boolean value, convert it to boolean here |
||
63 | * @return bool |
||
64 | */ |
||
65 | 5 | public function getResultBoolean(): bool |
|
69 | |||
70 | /** |
||
71 | * Hack: for some requests Telegram send back an array, integer, string or a boolean value, convert it to int here |
||
72 | * @return int |
||
73 | */ |
||
74 | 1 | public function getResultInt(): int |
|
78 | |||
79 | /** |
||
80 | * Hack: for some requests Telegram send back an array, integer, string or a boolean value, convert it to string here |
||
81 | * @return string |
||
82 | */ |
||
83 | public function getResultString(): string |
||
87 | } |
||
88 |