1 | <?php |
||
18 | abstract class TelegramMethods implements TelegramMethodDefinitions |
||
19 | { |
||
20 | /** |
||
21 | * Most of the methods will return a Message object on success, so set that as the default. |
||
22 | * |
||
23 | * This function may however be overwritten if the method uses another object, there are many examples of this, so |
||
24 | * just check out the rest of the code. A good place to start is GetUserProfilePhotos or LeaveChat |
||
25 | * |
||
26 | * @see unreal4u\TelegramAPI\Telegram\Methods\GetUserProfilePhotos |
||
27 | * @see unreal4u\TelegramAPI\Telegram\Methods\LeaveChat |
||
28 | * |
||
29 | * @param TelegramRawData $data |
||
30 | * @param LoggerInterface $logger |
||
31 | * |
||
32 | * @return TelegramTypes |
||
33 | */ |
||
34 | 8 | public static function bindToObject(TelegramRawData $data, LoggerInterface $logger): TelegramTypes |
|
38 | |||
39 | /** |
||
40 | * Before making the actual request this method will be called |
||
41 | * |
||
42 | * It must be used to json_encode stuff, or do other changes in the internal class representation _before_ sending |
||
43 | * it to the Telegram servers |
||
44 | * |
||
45 | * @return TelegramMethods |
||
46 | */ |
||
47 | 10 | public function performSpecialConditions(): TelegramMethods |
|
68 | |||
69 | /** |
||
70 | * Exports the class to an array in order to send it to the Telegram servers without extra fields that we don't need |
||
71 | * |
||
72 | * @return array |
||
73 | * @throws MissingMandatoryField |
||
74 | */ |
||
75 | 16 | final public function export(): array |
|
96 | |||
97 | /** |
||
98 | * Will resolve the dependency of a mandatory inline_message_id OR a chat_id + message_id |
||
99 | * |
||
100 | * NOTE: This will use pass by reference instead of copy on write as the use-case for this functions allows this |
||
101 | * |
||
102 | * @param array $return |
||
103 | * @return array |
||
104 | */ |
||
105 | 4 | final protected function mandatoryUserOrInlineMessageId(array &$return): array |
|
119 | |||
120 | /** |
||
121 | * ReplyMarkup fields require a bit of work before sending them |
||
122 | * |
||
123 | * This happens because reply markup are a type thus they don't have an export mechanism to do the job |
||
124 | * |
||
125 | * @param TelegramTypes $replyMarkup |
||
126 | * @return TelegramTypes |
||
127 | */ |
||
128 | 1 | final private function formatReplyMarkup(TelegramTypes $replyMarkup): TelegramTypes |
|
138 | |||
139 | 1 | final private function getArrayFromKeyboard(array $keyboardArray): array |
|
161 | |||
162 | /** |
||
163 | * Does the definitive export of those fields in a reply markup item that are filled in |
||
164 | * |
||
165 | * @param TelegramTypes $markupItem |
||
166 | * @return array |
||
167 | */ |
||
168 | final private function exportReplyMarkupItem(TelegramTypes $markupItem): array |
||
180 | } |
||
181 |
In PHP it is possible to write to properties without declaring them. For example, the following is perfectly valid PHP code:
Generally, it is a good practice to explictly declare properties to avoid accidental typos and provide IDE auto-completion: