1 | <?php |
||
26 | abstract class Entity |
||
27 | { |
||
28 | /** |
||
29 | * Entity constructor. |
||
30 | * |
||
31 | * @todo Get rid of the $bot_name, it shouldn't be here! |
||
32 | * |
||
33 | * @param array $data |
||
34 | * @param string $bot_name |
||
35 | * |
||
36 | * @throws \Longman\TelegramBot\Exception\TelegramException |
||
37 | */ |
||
38 | 78 | public function __construct($data, $bot_name = '') |
|
53 | |||
54 | /** |
||
55 | * Perform to json |
||
56 | * |
||
57 | * @return string |
||
58 | */ |
||
59 | 1 | public function toJson() |
|
63 | |||
64 | /** |
||
65 | * Perform to string |
||
66 | * |
||
67 | * @return string |
||
68 | */ |
||
69 | public function __toString() |
||
73 | |||
74 | /** |
||
75 | * Helper to set member variables |
||
76 | * |
||
77 | * @param array $data |
||
78 | */ |
||
79 | 78 | protected function assignMemberVariables(array $data) |
|
85 | |||
86 | /** |
||
87 | * Get the list of the properties that are themselves Entities |
||
88 | * |
||
89 | * @return array |
||
90 | */ |
||
91 | 53 | protected function subEntities() |
|
95 | |||
96 | /** |
||
97 | * Perform any special entity validation |
||
98 | * |
||
99 | * @throws \Longman\TelegramBot\Exception\TelegramException |
||
100 | */ |
||
101 | 51 | protected function validate() |
|
104 | |||
105 | /** |
||
106 | * Get a property from the current Entity |
||
107 | * |
||
108 | * @param mixed $property |
||
109 | * @param mixed $default |
||
110 | * |
||
111 | * @return mixed |
||
112 | */ |
||
113 | 73 | public function getProperty($property, $default = null) |
|
121 | |||
122 | /** |
||
123 | * Return the variable for the called getter or magically set properties dynamically. |
||
124 | * |
||
125 | * @param $method |
||
126 | * @param $args |
||
127 | * |
||
128 | * @return mixed|null |
||
129 | */ |
||
130 | 59 | public function __call($method, $args) |
|
160 | |||
161 | /** |
||
162 | * Return an array of nice objects from an array of object arrays |
||
163 | * |
||
164 | * This method is used to generate pretty object arrays |
||
165 | * mainly for PhotoSize and Entities object arrays. |
||
166 | * |
||
167 | * @param string $class |
||
168 | * @param string $property |
||
169 | * |
||
170 | * @return array |
||
171 | */ |
||
172 | 6 | protected function makePrettyObjectArray($class, $property) |
|
190 | |||
191 | /** |
||
192 | * Escape markdown special characters |
||
193 | * |
||
194 | * @param string $string |
||
195 | * |
||
196 | * @return string |
||
197 | */ |
||
198 | 1 | public function escapeMarkdown($string) |
|
206 | |||
207 | /** |
||
208 | * Try to mention the user |
||
209 | * |
||
210 | * Mention the user with the username otherwise print first and last name |
||
211 | * if the $escape_markdown argument is true special characters are escaped from the output |
||
212 | * |
||
213 | * @param bool $escape_markdown |
||
214 | * |
||
215 | * @return string|null |
||
216 | */ |
||
217 | 3 | public function tryMention($escape_markdown = false) |
|
243 | } |
||
244 |