1 | <?php |
||
27 | abstract class Entity |
||
28 | { |
||
29 | /** |
||
30 | * Entity constructor. |
||
31 | * |
||
32 | * @todo Get rid of the $bot_name, it shouldn't be here! |
||
33 | * |
||
34 | * @param array $data |
||
35 | * @param string $bot_name |
||
36 | * |
||
37 | * @throws \Longman\TelegramBot\Exception\TelegramException |
||
38 | */ |
||
39 | 81 | public function __construct($data, $bot_name = '') |
|
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 | 81 | protected function assignMemberVariables(array $data) |
|
86 | |||
87 | /** |
||
88 | * Get the list of the properties that are themselves Entities |
||
89 | * |
||
90 | * @return array |
||
91 | */ |
||
92 | 56 | protected function subEntities() |
|
96 | |||
97 | /** |
||
98 | * Perform any special entity validation |
||
99 | * |
||
100 | * @throws \Longman\TelegramBot\Exception\TelegramException |
||
101 | */ |
||
102 | 54 | 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 | 76 | 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 | 63 | public function __call($method, $args) |
|
161 | |||
162 | /** |
||
163 | * Return an array of nice objects from an array of object arrays |
||
164 | * |
||
165 | * This method is used to generate pretty object arrays |
||
166 | * mainly for PhotoSize and Entities object arrays. |
||
167 | * |
||
168 | * @param string $class |
||
169 | * @param string $property |
||
170 | * |
||
171 | * @return array |
||
172 | */ |
||
173 | 6 | protected function makePrettyObjectArray($class, $property) |
|
191 | |||
192 | /** |
||
193 | * Escape markdown special characters |
||
194 | * |
||
195 | * @param string $string |
||
196 | * |
||
197 | * @return string |
||
198 | */ |
||
199 | 1 | public function escapeMarkdown($string) |
|
207 | |||
208 | /** |
||
209 | * Try to mention the user |
||
210 | * |
||
211 | * Mention the user with the username otherwise print first and last name |
||
212 | * if the $escape_markdown argument is true special characters are escaped from the output |
||
213 | * |
||
214 | * @param bool $escape_markdown |
||
215 | * |
||
216 | * @return string|null |
||
217 | */ |
||
218 | 3 | public function tryMention($escape_markdown = false) |
|
244 | } |
||
245 |