1 | <?php |
||
23 | abstract class AbstractMethod { |
||
24 | |||
25 | use Property; |
||
26 | |||
27 | const NAME = null; |
||
28 | |||
29 | const RETURN_ENTITY = null; |
||
30 | |||
31 | protected $parent = null; |
||
32 | |||
33 | protected $hasAttachedData = false; |
||
34 | |||
35 | protected $reply_markup; |
||
36 | |||
37 | /** |
||
38 | * List of properties supported by method in format: property name => required or not |
||
39 | * |
||
40 | * @var array |
||
41 | */ |
||
42 | protected $supportedProperties = []; |
||
43 | |||
44 | protected $supportedMarkups = [ |
||
45 | InlineKeyboardMarkup::class, |
||
46 | ReplyKeyboardMarkup::class, |
||
47 | ReplyKeyboardHide::class, |
||
48 | ForceReply::class |
||
49 | ]; |
||
50 | |||
51 | /** |
||
52 | * Constructs extended method's class and sets properties from array if passed. |
||
53 | * |
||
54 | * @param array $args |
||
55 | */ |
||
56 | public function __construct($args = []) |
||
64 | |||
65 | /** |
||
66 | * Returns method's name. |
||
67 | * |
||
68 | * @return string |
||
69 | */ |
||
70 | public function getName() |
||
74 | |||
75 | /** |
||
76 | * Returns entity's name that should be return in method execution result. |
||
77 | * |
||
78 | * @return string |
||
79 | */ |
||
80 | public function getReturnEntity() |
||
84 | |||
85 | /** |
||
86 | * Triggers execution of the method |
||
87 | * |
||
88 | * @param bool $silentMode Execute method silently without processing the result |
||
89 | * |
||
90 | * @return \Teebot\Response |
||
91 | */ |
||
92 | public function trigger($silentMode = true) |
||
98 | |||
99 | /** |
||
100 | * Returns flag which idicates that method has attached data (audio, voice, video, photo etc.) |
||
101 | * |
||
102 | * @return bool |
||
103 | */ |
||
104 | public function hasAttachedData() |
||
108 | |||
109 | /** |
||
110 | * Checks that passed markup is currently supported |
||
111 | * |
||
112 | * @param AbstractEntity $markup Markup class instance |
||
113 | * |
||
114 | * @return bool |
||
115 | */ |
||
116 | protected function isValidMarkup(AbstractEntity $markup) |
||
126 | |||
127 | /** |
||
128 | * Sets reply markup class |
||
129 | * |
||
130 | * @param AbstractEntity $markup Markup class instance |
||
131 | * |
||
132 | * @return $this |
||
133 | */ |
||
134 | public function setReplyMarkup(AbstractEntity $markup) |
||
152 | |||
153 | /** |
||
154 | * Returns reply markup as JSON encoded string if reply_markup is an instance of AbstractEntity |
||
155 | * |
||
156 | * @return string|mixed |
||
157 | */ |
||
158 | public function getReplyMarkup() |
||
167 | |||
168 | /** |
||
169 | * Returns parent entity which triggered method's execution. |
||
170 | * |
||
171 | * @return AbstractEntity |
||
172 | */ |
||
173 | public function getParent() |
||
177 | |||
178 | /** |
||
179 | * Sets parent entity which triggered method's execution. |
||
180 | * |
||
181 | * @param AbstractEntity $parent |
||
182 | * |
||
183 | * @return $this |
||
184 | */ |
||
185 | public function setParent(AbstractEntity $parent) |
||
191 | } |
||
192 |