1 | <?php |
||
27 | abstract class Entity |
||
28 | { |
||
29 | /** |
||
30 | * Entity constructor. |
||
31 | * |
||
32 | * @todo Get rid of the $bot_username, it shouldn't be here! |
||
33 | * |
||
34 | * @param array $data |
||
35 | * @param string $bot_username |
||
36 | * |
||
37 | * @throws \Longman\TelegramBot\Exception\TelegramException |
||
38 | */ |
||
39 | 77 | public function __construct($data, $bot_username = '') |
|
54 | |||
55 | /** |
||
56 | * Perform to json |
||
57 | * |
||
58 | * @return string |
||
59 | */ |
||
60 | 1 | public function toJson() |
|
64 | |||
65 | /** |
||
66 | * Perform to string |
||
67 | * |
||
68 | * @return string |
||
69 | */ |
||
70 | public function __toString() |
||
74 | |||
75 | /** |
||
76 | * Helper to set member variables |
||
77 | * |
||
78 | * @param array $data |
||
79 | */ |
||
80 | 77 | protected function assignMemberVariables(array $data) |
|
86 | |||
87 | /** |
||
88 | * Get the list of the properties that are themselves Entities |
||
89 | * |
||
90 | * @return array |
||
91 | */ |
||
92 | 47 | protected function subEntities() |
|
96 | |||
97 | /** |
||
98 | * Perform any special entity validation |
||
99 | * |
||
100 | * @throws \Longman\TelegramBot\Exception\TelegramException |
||
101 | */ |
||
102 | 52 | protected function validate() |
|
105 | |||
106 | /** |
||
107 | * Get a property from the current Entity |
||
108 | * |
||
109 | * @param mixed $property |
||
110 | * @param mixed $default |
||
111 | * |
||
112 | * @return mixed |
||
113 | */ |
||
114 | 71 | public function getProperty($property, $default = null) |
|
122 | |||
123 | /** |
||
124 | * Return the variable for the called getter or magically set properties dynamically. |
||
125 | * |
||
126 | * @param $method |
||
127 | * @param $args |
||
128 | * |
||
129 | * @return mixed|null |
||
130 | */ |
||
131 | 58 | public function __call($method, $args) |
|
167 | |||
168 | /** |
||
169 | * Return an array of nice objects from an array of object arrays |
||
170 | * |
||
171 | * This method is used to generate pretty object arrays |
||
172 | * mainly for PhotoSize and Entities object arrays. |
||
173 | * |
||
174 | * @param string $class |
||
175 | * @param string $property |
||
176 | * |
||
177 | * @return array |
||
178 | */ |
||
179 | 1 | protected function makePrettyObjectArray($class, $property) |
|
197 | |||
198 | /** |
||
199 | * Escape markdown special characters |
||
200 | * |
||
201 | * @param string $string |
||
202 | * |
||
203 | * @return string |
||
204 | */ |
||
205 | 1 | public function escapeMarkdown($string) |
|
213 | |||
214 | /** |
||
215 | * Try to mention the user |
||
216 | * |
||
217 | * Mention the user with the username otherwise print first and last name |
||
218 | * if the $escape_markdown argument is true special characters are escaped from the output |
||
219 | * |
||
220 | * @param bool $escape_markdown |
||
221 | * |
||
222 | * @return string|null |
||
223 | */ |
||
224 | 3 | public function tryMention($escape_markdown = false) |
|
250 | } |
||
251 |