Passed
Push — master ( 2ab801...3e09d8 )
by Shahrad
10:07
created
src/lib/Request.php 1 patch
Indentation   +222 added lines, -222 removed lines patch added patch discarded remove patch
@@ -143,227 +143,227 @@
 block discarded – undo
143 143
 class Request
144 144
 {
145 145
 
146
-	/**
147
-	 * Available fields for InputFile helper
148
-	 *
149
-	 * This is basically the list of all fields that allow InputFile objects
150
-	 * for which input can be simplified by providing local path directly  as string.
151
-	 *
152
-	 * @var array
153
-	 */
154
-	private static array $input_file_fields = [
155
-		'setWebhook' => ['certificate'],
156
-		'sendPhoto' => ['photo'],
157
-		'sendAudio' => ['audio', 'thumb'],
158
-		'sendDocument' => ['document', 'thumb'],
159
-		'sendVideo' => ['video', 'thumb'],
160
-		'sendAnimation' => ['animation', 'thumb'],
161
-		'sendVoice' => ['voice', 'thumb'],
162
-		'sendVideoNote' => ['video_note', 'thumb'],
163
-		'setChatPhoto' => ['photo'],
164
-		'sendSticker' => ['sticker'],
165
-		'uploadStickerFile' => ['png_sticker'],
166
-		'createNewStickerSet' => ['png_sticker', 'tgs_sticker', 'webm_sticker'],
167
-		'addStickerToSet' => ['png_sticker', 'tgs_sticker', 'webm_sticker'],
168
-		'setStickerSetThumb' => ['thumb'],
169
-	];
170
-
171
-	/**
172
-	 * URI of the Telegram API
173
-	 *
174
-	 * @var string
175
-	 */
176
-	private static string $api_base_uri = 'https://api.telegram.org';
177
-
178
-	/**
179
-	 * URI of the Telegram API for downloading files (relative to $api_base_url or absolute)
180
-	 *
181
-	 * @var string
182
-	 */
183
-	private static string $api_base_download_uri = '/file/bot{API_KEY}';
184
-
185
-	/**
186
-	 * The current action that is being executed
187
-	 *
188
-	 * @var string
189
-	 */
190
-	private static string $current_action = '';
191
-
192
-	/**
193
-	 * Get the Telegram API path
194
-	 *
195
-	 * @return string
196
-	 */
197
-	public static function getApiPath(): string
198
-	{
199
-		return self::$api_base_uri . '/bot' . Telegram::getApiKey() . '/';
200
-	}
201
-
202
-	/**
203
-	 * Initialize a http client
204
-	 *
205
-	 * @return Client
206
-	 */
207
-	private static function getClient(): Client
208
-	{
209
-		return new Client();
210
-	}
211
-
212
-	/**
213
-	 * Use this method to get stats of given user in a supergroup or channel.
214
-	 *
215
-	 * @param int $user_id User identifier
216
-	 * @param int $chat_id Identifier of the chat to get stats for
217
-	 *
218
-	 * @return string [left, member, administrator, creator]
219
-	 */
220
-	public static function getChatMemberStatus(int $user_id, int $chat_id): string
221
-	{
222
-		$response = self::getChatMember([
223
-			'user_id' => $user_id,
224
-			'chat_id' => $chat_id,
225
-		]);
226
-
227
-		return $response->getResult()->status ?? "left";
228
-	}
229
-
230
-	/**
231
-	 * Properly set up the request params
232
-	 *
233
-	 * If any item of the array is a resource, reformat it to a multipart request.
234
-	 * Else, just return the passed data as form params.
235
-	 *
236
-	 * @param array $data
237
-	 * @return array
238
-	 */
239
-	private static function setUpRequestParams(array $data): array
240
-	{
241
-		$multipart = [];
242
-		$has_resource = false;
243
-
244
-		$options = [
245
-			'header' => [
246
-				'Content-Type' => 'application/json',
247
-				'Accept' => 'application/json',
248
-				'User-Agent' => 'TelegramBot-PHP/' . Telegram::$VERSION
249
-			]
250
-		];
251
-
252
-		foreach ($data as $key => &$item) {
253
-			if (array_key_exists(self::$current_action, self::$input_file_fields) && in_array($key, self::$input_file_fields[self::$current_action], true)) {
254
-
255
-				if (is_string($item) && file_exists($item)) {
256
-					$has_resource = true;
257
-
258
-				} elseif (filter_var($item, FILTER_VALIDATE_URL)) {
259
-					$has_resource = false;
260
-					continue;
261
-
262
-				} else {
263
-					throw new TelegramException(
264
-						'Invalid file path or URL: ' . $item . ' for ' . self::$current_action . ' action'
265
-					);
266
-				}
267
-
268
-				$multipart[$key] = $item;
269
-				continue;
270
-			}
271
-
272
-			if ($item instanceof Entity) {
273
-				$item = $item->getRawData();
274
-			}
275
-
276
-			if (is_array($item)) {
277
-				$item = json_encode($item);
278
-			}
279
-
280
-			$options['query'][$key] = $item;
281
-		}
282
-		unset($item);
283
-
284
-		if ($has_resource) {
285
-			$options['multipart'] = FormData::create($multipart);
286
-		}
287
-
288
-		return $options;
289
-	}
290
-
291
-	/**
292
-	 * Create a Http Request
293
-	 *
294
-	 * @param string $action Action to execute
295
-	 * @param array $data Data to attach to the execution
296
-	 *
297
-	 * @return array An array of the setUpRequestParams and the url
298
-	 */
299
-	public static function create(string $action, array $data): array
300
-	{
301
-		return [
302
-			'url' => self::getApiPath() . $action,
303
-			'options' => self::setUpRequestParams($data)
304
-		];
305
-	}
306
-
307
-	/**
308
-	 * Execute HTTP Request
309
-	 *
310
-	 * @param string $action Action to execute
311
-	 * @param array $data Data to attach to the execution
312
-	 *
313
-	 * @return string Result of the HTTP Request
314
-	 */
315
-	private static function execute(string $action, array $data): string
316
-	{
317
-		$request = self::create($action, $data);
318
-
319
-		$response = self::getClient()->get($request['url'], $request['options']);
320
-
321
-		return $response->getBody();
322
-	}
323
-
324
-	/**
325
-	 * Send command
326
-	 *
327
-	 * @param string $action
328
-	 * @param array $data
329
-	 *
330
-	 * @return Response
331
-	 * @throws TelegramException
332
-	 */
333
-	public static function send(string $action, array $data = []): Response
334
-	{
335
-		self::$current_action = $action;
336
-
337
-		$raw_response = self::execute($action, $data);
338
-
339
-		if (!Common::isJson($raw_response)) {
340
-			TelegramLog::debug($raw_response);
341
-			throw new TelegramException('Invalid response from API');
342
-		}
343
-
344
-		$response = new Response(json_decode($raw_response, true));
345
-
346
-		if (!$response->isOk() && $response->getErrorCode() === 401 && $response->getDescription() === 'Unauthorized') {
347
-			throw new InvalidBotTokenException();
348
-		}
349
-
350
-		self::$current_action = '';
351
-
352
-		return $response;
353
-	}
354
-
355
-	/**
356
-	 * Any statically called method should be relayed to the `send` method.
357
-	 *
358
-	 * @param string $action
359
-	 * @param array $data
360
-	 *
361
-	 * @return Response
362
-	 * @throws TelegramException
363
-	 */
364
-	public static function __callStatic(string $action, array $data): Response
365
-	{
366
-		return static::send($action, reset($data) ?: []);
367
-	}
146
+    /**
147
+     * Available fields for InputFile helper
148
+     *
149
+     * This is basically the list of all fields that allow InputFile objects
150
+     * for which input can be simplified by providing local path directly  as string.
151
+     *
152
+     * @var array
153
+     */
154
+    private static array $input_file_fields = [
155
+        'setWebhook' => ['certificate'],
156
+        'sendPhoto' => ['photo'],
157
+        'sendAudio' => ['audio', 'thumb'],
158
+        'sendDocument' => ['document', 'thumb'],
159
+        'sendVideo' => ['video', 'thumb'],
160
+        'sendAnimation' => ['animation', 'thumb'],
161
+        'sendVoice' => ['voice', 'thumb'],
162
+        'sendVideoNote' => ['video_note', 'thumb'],
163
+        'setChatPhoto' => ['photo'],
164
+        'sendSticker' => ['sticker'],
165
+        'uploadStickerFile' => ['png_sticker'],
166
+        'createNewStickerSet' => ['png_sticker', 'tgs_sticker', 'webm_sticker'],
167
+        'addStickerToSet' => ['png_sticker', 'tgs_sticker', 'webm_sticker'],
168
+        'setStickerSetThumb' => ['thumb'],
169
+    ];
170
+
171
+    /**
172
+     * URI of the Telegram API
173
+     *
174
+     * @var string
175
+     */
176
+    private static string $api_base_uri = 'https://api.telegram.org';
177
+
178
+    /**
179
+     * URI of the Telegram API for downloading files (relative to $api_base_url or absolute)
180
+     *
181
+     * @var string
182
+     */
183
+    private static string $api_base_download_uri = '/file/bot{API_KEY}';
184
+
185
+    /**
186
+     * The current action that is being executed
187
+     *
188
+     * @var string
189
+     */
190
+    private static string $current_action = '';
191
+
192
+    /**
193
+     * Get the Telegram API path
194
+     *
195
+     * @return string
196
+     */
197
+    public static function getApiPath(): string
198
+    {
199
+        return self::$api_base_uri . '/bot' . Telegram::getApiKey() . '/';
200
+    }
201
+
202
+    /**
203
+     * Initialize a http client
204
+     *
205
+     * @return Client
206
+     */
207
+    private static function getClient(): Client
208
+    {
209
+        return new Client();
210
+    }
211
+
212
+    /**
213
+     * Use this method to get stats of given user in a supergroup or channel.
214
+     *
215
+     * @param int $user_id User identifier
216
+     * @param int $chat_id Identifier of the chat to get stats for
217
+     *
218
+     * @return string [left, member, administrator, creator]
219
+     */
220
+    public static function getChatMemberStatus(int $user_id, int $chat_id): string
221
+    {
222
+        $response = self::getChatMember([
223
+            'user_id' => $user_id,
224
+            'chat_id' => $chat_id,
225
+        ]);
226
+
227
+        return $response->getResult()->status ?? "left";
228
+    }
229
+
230
+    /**
231
+     * Properly set up the request params
232
+     *
233
+     * If any item of the array is a resource, reformat it to a multipart request.
234
+     * Else, just return the passed data as form params.
235
+     *
236
+     * @param array $data
237
+     * @return array
238
+     */
239
+    private static function setUpRequestParams(array $data): array
240
+    {
241
+        $multipart = [];
242
+        $has_resource = false;
243
+
244
+        $options = [
245
+            'header' => [
246
+                'Content-Type' => 'application/json',
247
+                'Accept' => 'application/json',
248
+                'User-Agent' => 'TelegramBot-PHP/' . Telegram::$VERSION
249
+            ]
250
+        ];
251
+
252
+        foreach ($data as $key => &$item) {
253
+            if (array_key_exists(self::$current_action, self::$input_file_fields) && in_array($key, self::$input_file_fields[self::$current_action], true)) {
254
+
255
+                if (is_string($item) && file_exists($item)) {
256
+                    $has_resource = true;
257
+
258
+                } elseif (filter_var($item, FILTER_VALIDATE_URL)) {
259
+                    $has_resource = false;
260
+                    continue;
261
+
262
+                } else {
263
+                    throw new TelegramException(
264
+                        'Invalid file path or URL: ' . $item . ' for ' . self::$current_action . ' action'
265
+                    );
266
+                }
267
+
268
+                $multipart[$key] = $item;
269
+                continue;
270
+            }
271
+
272
+            if ($item instanceof Entity) {
273
+                $item = $item->getRawData();
274
+            }
275
+
276
+            if (is_array($item)) {
277
+                $item = json_encode($item);
278
+            }
279
+
280
+            $options['query'][$key] = $item;
281
+        }
282
+        unset($item);
283
+
284
+        if ($has_resource) {
285
+            $options['multipart'] = FormData::create($multipart);
286
+        }
287
+
288
+        return $options;
289
+    }
290
+
291
+    /**
292
+     * Create a Http Request
293
+     *
294
+     * @param string $action Action to execute
295
+     * @param array $data Data to attach to the execution
296
+     *
297
+     * @return array An array of the setUpRequestParams and the url
298
+     */
299
+    public static function create(string $action, array $data): array
300
+    {
301
+        return [
302
+            'url' => self::getApiPath() . $action,
303
+            'options' => self::setUpRequestParams($data)
304
+        ];
305
+    }
306
+
307
+    /**
308
+     * Execute HTTP Request
309
+     *
310
+     * @param string $action Action to execute
311
+     * @param array $data Data to attach to the execution
312
+     *
313
+     * @return string Result of the HTTP Request
314
+     */
315
+    private static function execute(string $action, array $data): string
316
+    {
317
+        $request = self::create($action, $data);
318
+
319
+        $response = self::getClient()->get($request['url'], $request['options']);
320
+
321
+        return $response->getBody();
322
+    }
323
+
324
+    /**
325
+     * Send command
326
+     *
327
+     * @param string $action
328
+     * @param array $data
329
+     *
330
+     * @return Response
331
+     * @throws TelegramException
332
+     */
333
+    public static function send(string $action, array $data = []): Response
334
+    {
335
+        self::$current_action = $action;
336
+
337
+        $raw_response = self::execute($action, $data);
338
+
339
+        if (!Common::isJson($raw_response)) {
340
+            TelegramLog::debug($raw_response);
341
+            throw new TelegramException('Invalid response from API');
342
+        }
343
+
344
+        $response = new Response(json_decode($raw_response, true));
345
+
346
+        if (!$response->isOk() && $response->getErrorCode() === 401 && $response->getDescription() === 'Unauthorized') {
347
+            throw new InvalidBotTokenException();
348
+        }
349
+
350
+        self::$current_action = '';
351
+
352
+        return $response;
353
+    }
354
+
355
+    /**
356
+     * Any statically called method should be relayed to the `send` method.
357
+     *
358
+     * @param string $action
359
+     * @param array $data
360
+     *
361
+     * @return Response
362
+     * @throws TelegramException
363
+     */
364
+    public static function __callStatic(string $action, array $data): Response
365
+    {
366
+        return static::send($action, reset($data) ?: []);
367
+    }
368 368
 
369 369
 }
Please login to merge, or discard this patch.
src/lib/Entities/Keyboard.php 1 patch
Indentation   +98 added lines, -98 removed lines patch added patch discarded remove patch
@@ -23,103 +23,103 @@
 block discarded – undo
23 23
 class Keyboard extends Entity
24 24
 {
25 25
 
26
-	public function __construct(array $data = [])
27
-	{
28
-		parent::__construct(array_merge($data, [
29
-			'resize_keyboard' => false,
30
-			'one_time_keyboard' => false,
31
-			'input_field_placeholder' => '',
32
-			'selective' => false
33
-		]));
34
-	}
35
-
36
-	/**
37
-	 * Create a new row in keyboard and add buttons.
38
-	 *
39
-	 * @param array<KeyboardButton> $row
40
-	 * @return Keyboard
41
-	 */
42
-	public function addRow(array $row): Keyboard
43
-	{
44
-		$keyboard_type = self::getType();
45
-
46
-		if (!isset($this->raw_data[$keyboard_type]) || !is_array($this->raw_data[$keyboard_type])) {
47
-			$this->raw_data[$keyboard_type] = [];
48
-		}
49
-
50
-		$new_row = [];
51
-		foreach ($row as $button) {
52
-			$new_row[] = $button->getRawData();
53
-		}
54
-
55
-		$this->raw_data[$keyboard_type][] = $new_row;
56
-
57
-		return $this;
58
-	}
59
-
60
-	/**
61
-	 * Remove the current custom keyboard and display the default letter-keyboard.
62
-	 *
63
-	 * @link https://core.telegram.org/bots/api/#replykeyboardremove
64
-	 *
65
-	 * @param array $data
66
-	 *
67
-	 * @return Keyboard
68
-	 */
69
-	public static function remove(array $data = []): Keyboard
70
-	{
71
-		return new static(array_merge(['keyboard' => [], 'remove_keyboard' => true, 'selective' => false], $data));
72
-	}
73
-
74
-	/**
75
-	 * Display a reply interface to the user (act as if the user has selected the bot's message and tapped 'Reply').
76
-	 *
77
-	 * @link https://core.telegram.org/bots/api#forcereply
78
-	 *
79
-	 * @param array $data
80
-	 *
81
-	 * @return Keyboard
82
-	 */
83
-	public static function forceReply(array $data = []): Keyboard
84
-	{
85
-		return new static(array_merge(['keyboard' => [], 'force_reply' => true, 'selective' => false], $data));
86
-	}
87
-
88
-	/**
89
-	 * Get keyboard button type
90
-	 *
91
-	 * @return string ["keyboard"|"inline_keyboard"]
92
-	 */
93
-	public function getType(): string
94
-	{
95
-		$reflection = new \ReflectionClass(static::class);
96
-
97
-		$class_name = $reflection->getShortName();
98
-
99
-		return strtolower(ltrim(preg_replace('/[A-Z]/', '_$0', $class_name), '_'));
100
-	}
101
-
102
-	/**
103
-	 * Creates instance of Keyboard
104
-	 *
105
-	 * @return Keyboard
106
-	 */
107
-	public static function make(): Keyboard
108
-	{
109
-		return new self();
110
-	}
111
-
112
-	/**
113
-	 * @param array $rows
114
-	 * @return Keyboard
115
-	 */
116
-	public function setKeyboard(array $rows): Keyboard
117
-	{
118
-		foreach ($rows as $row) {
119
-			$this->addRow($row);
120
-		}
121
-
122
-		return $this;
123
-	}
26
+    public function __construct(array $data = [])
27
+    {
28
+        parent::__construct(array_merge($data, [
29
+            'resize_keyboard' => false,
30
+            'one_time_keyboard' => false,
31
+            'input_field_placeholder' => '',
32
+            'selective' => false
33
+        ]));
34
+    }
35
+
36
+    /**
37
+     * Create a new row in keyboard and add buttons.
38
+     *
39
+     * @param array<KeyboardButton> $row
40
+     * @return Keyboard
41
+     */
42
+    public function addRow(array $row): Keyboard
43
+    {
44
+        $keyboard_type = self::getType();
45
+
46
+        if (!isset($this->raw_data[$keyboard_type]) || !is_array($this->raw_data[$keyboard_type])) {
47
+            $this->raw_data[$keyboard_type] = [];
48
+        }
49
+
50
+        $new_row = [];
51
+        foreach ($row as $button) {
52
+            $new_row[] = $button->getRawData();
53
+        }
54
+
55
+        $this->raw_data[$keyboard_type][] = $new_row;
56
+
57
+        return $this;
58
+    }
59
+
60
+    /**
61
+     * Remove the current custom keyboard and display the default letter-keyboard.
62
+     *
63
+     * @link https://core.telegram.org/bots/api/#replykeyboardremove
64
+     *
65
+     * @param array $data
66
+     *
67
+     * @return Keyboard
68
+     */
69
+    public static function remove(array $data = []): Keyboard
70
+    {
71
+        return new static(array_merge(['keyboard' => [], 'remove_keyboard' => true, 'selective' => false], $data));
72
+    }
73
+
74
+    /**
75
+     * Display a reply interface to the user (act as if the user has selected the bot's message and tapped 'Reply').
76
+     *
77
+     * @link https://core.telegram.org/bots/api#forcereply
78
+     *
79
+     * @param array $data
80
+     *
81
+     * @return Keyboard
82
+     */
83
+    public static function forceReply(array $data = []): Keyboard
84
+    {
85
+        return new static(array_merge(['keyboard' => [], 'force_reply' => true, 'selective' => false], $data));
86
+    }
87
+
88
+    /**
89
+     * Get keyboard button type
90
+     *
91
+     * @return string ["keyboard"|"inline_keyboard"]
92
+     */
93
+    public function getType(): string
94
+    {
95
+        $reflection = new \ReflectionClass(static::class);
96
+
97
+        $class_name = $reflection->getShortName();
98
+
99
+        return strtolower(ltrim(preg_replace('/[A-Z]/', '_$0', $class_name), '_'));
100
+    }
101
+
102
+    /**
103
+     * Creates instance of Keyboard
104
+     *
105
+     * @return Keyboard
106
+     */
107
+    public static function make(): Keyboard
108
+    {
109
+        return new self();
110
+    }
111
+
112
+    /**
113
+     * @param array $rows
114
+     * @return Keyboard
115
+     */
116
+    public function setKeyboard(array $rows): Keyboard
117
+    {
118
+        foreach ($rows as $row) {
119
+            $this->addRow($row);
120
+        }
121
+
122
+        return $this;
123
+    }
124 124
 
125 125
 }
Please login to merge, or discard this patch.
src/lib/Entities/Update.php 1 patch
Indentation   +61 added lines, -61 removed lines patch added patch discarded remove patch
@@ -32,70 +32,70 @@
 block discarded – undo
32 32
 class Update extends Entity
33 33
 {
34 34
 
35
-	public const TYPE_MESSAGE = 'message';
36
-	public const TYPE_EDITED_MESSAGE = 'edited_message';
37
-	public const TYPE_CHANNEL_POST = 'channel_post';
38
-	public const TYPE_EDITED_CHANNEL_POST = 'edited_channel_post';
39
-	public const TYPE_INLINE_QUERY = 'inline_query';
40
-	public const TYPE_CHOSEN_INLINE_RESULT = 'chosen_inline_result';
41
-	public const TYPE_CALLBACK_QUERY = 'callback_query';
42
-	public const TYPE_SHIPPING_QUERY = 'shipping_query';
43
-	public const TYPE_PRE_CHECKOUT_QUERY = 'pre_checkout_query';
44
-	public const TYPE_POLL = 'poll';
45
-	public const TYPE_POLL_ANSWER = 'poll_answer';
46
-	public const TYPE_MY_CHAT_MEMBER = 'my_chat_member';
47
-	public const TYPE_CHAT_MEMBER = 'chat_member';
48
-	public const TYPE_CHAT_JOIN_REQUEST = 'chat_join_request';
49
-	public const TYPE_WEB_DATA = 'web_data';
35
+    public const TYPE_MESSAGE = 'message';
36
+    public const TYPE_EDITED_MESSAGE = 'edited_message';
37
+    public const TYPE_CHANNEL_POST = 'channel_post';
38
+    public const TYPE_EDITED_CHANNEL_POST = 'edited_channel_post';
39
+    public const TYPE_INLINE_QUERY = 'inline_query';
40
+    public const TYPE_CHOSEN_INLINE_RESULT = 'chosen_inline_result';
41
+    public const TYPE_CALLBACK_QUERY = 'callback_query';
42
+    public const TYPE_SHIPPING_QUERY = 'shipping_query';
43
+    public const TYPE_PRE_CHECKOUT_QUERY = 'pre_checkout_query';
44
+    public const TYPE_POLL = 'poll';
45
+    public const TYPE_POLL_ANSWER = 'poll_answer';
46
+    public const TYPE_MY_CHAT_MEMBER = 'my_chat_member';
47
+    public const TYPE_CHAT_MEMBER = 'chat_member';
48
+    public const TYPE_CHAT_JOIN_REQUEST = 'chat_join_request';
49
+    public const TYPE_WEB_DATA = 'web_data';
50 50
 
51
-	/**
52
-	 * {@inheritdoc}
53
-	 */
54
-	protected function subEntities(): array
55
-	{
56
-		return [
57
-			self::TYPE_MESSAGE => Message::class,
58
-			self::TYPE_EDITED_MESSAGE => EditedMessage::class,
59
-			self::TYPE_CHANNEL_POST => ChannelPost::class,
60
-			self::TYPE_EDITED_CHANNEL_POST => EditedChannelPost::class,
61
-			self::TYPE_INLINE_QUERY => InlineQuery::class,
62
-			self::TYPE_CHOSEN_INLINE_RESULT => ChosenInlineResult::class,
63
-			self::TYPE_CALLBACK_QUERY => CallbackQuery::class,
64
-			self::TYPE_SHIPPING_QUERY => ShippingQuery::class,
65
-			self::TYPE_PRE_CHECKOUT_QUERY => PreCheckoutQuery::class,
66
-			self::TYPE_POLL => Poll::class,
67
-			self::TYPE_POLL_ANSWER => PollAnswer::class,
68
-			self::TYPE_MY_CHAT_MEMBER => ChatMemberUpdated::class,
69
-			self::TYPE_CHAT_MEMBER => ChatMemberUpdated::class,
70
-			self::TYPE_CHAT_JOIN_REQUEST => ChatJoinRequest::class,
71
-			self::TYPE_WEB_DATA => WebAppData::class,
72
-		];
73
-	}
51
+    /**
52
+     * {@inheritdoc}
53
+     */
54
+    protected function subEntities(): array
55
+    {
56
+        return [
57
+            self::TYPE_MESSAGE => Message::class,
58
+            self::TYPE_EDITED_MESSAGE => EditedMessage::class,
59
+            self::TYPE_CHANNEL_POST => ChannelPost::class,
60
+            self::TYPE_EDITED_CHANNEL_POST => EditedChannelPost::class,
61
+            self::TYPE_INLINE_QUERY => InlineQuery::class,
62
+            self::TYPE_CHOSEN_INLINE_RESULT => ChosenInlineResult::class,
63
+            self::TYPE_CALLBACK_QUERY => CallbackQuery::class,
64
+            self::TYPE_SHIPPING_QUERY => ShippingQuery::class,
65
+            self::TYPE_PRE_CHECKOUT_QUERY => PreCheckoutQuery::class,
66
+            self::TYPE_POLL => Poll::class,
67
+            self::TYPE_POLL_ANSWER => PollAnswer::class,
68
+            self::TYPE_MY_CHAT_MEMBER => ChatMemberUpdated::class,
69
+            self::TYPE_CHAT_MEMBER => ChatMemberUpdated::class,
70
+            self::TYPE_CHAT_JOIN_REQUEST => ChatJoinRequest::class,
71
+            self::TYPE_WEB_DATA => WebAppData::class,
72
+        ];
73
+    }
74 74
 
75
-	/**
76
-	 * Get the list of all available update types
77
-	 *
78
-	 * @return string[]
79
-	 */
80
-	public static function getUpdateTypes(): array
81
-	{
82
-		return array_keys((new self([]))->subEntities());
83
-	}
75
+    /**
76
+     * Get the list of all available update types
77
+     *
78
+     * @return string[]
79
+     */
80
+    public static function getUpdateTypes(): array
81
+    {
82
+        return array_keys((new self([]))->subEntities());
83
+    }
84 84
 
85
-	/**
86
-	 * Get the update type based on the set properties
87
-	 *
88
-	 * @return string|null
89
-	 */
90
-	public function getUpdateType(): ?string
91
-	{
92
-		foreach (self::getUpdateTypes() as $type) {
93
-			if ($this->getProperty($type)) {
94
-				return $type;
95
-			}
96
-		}
85
+    /**
86
+     * Get the update type based on the set properties
87
+     *
88
+     * @return string|null
89
+     */
90
+    public function getUpdateType(): ?string
91
+    {
92
+        foreach (self::getUpdateTypes() as $type) {
93
+            if ($this->getProperty($type)) {
94
+                return $type;
95
+            }
96
+        }
97 97
 
98
-		return null;
99
-	}
98
+        return null;
99
+    }
100 100
 
101 101
 }
Please login to merge, or discard this patch.
src/lib/WebhookHandler.php 2 patches
Braces   +11 added lines, -4 removed lines patch added patch discarded remove patch
@@ -156,10 +156,15 @@  discard block
 block discarded – undo
156 156
 			throw new \RuntimeException(sprintf('The method %s does not exist', $method));
157 157
 		}
158 158
 
159
-		if (is_array($config)) $this->updateConfiguration($config);
159
+		if (is_array($config)) {
160
+		    $this->updateConfiguration($config);
161
+		}
160 162
 
161
-		if (!empty($update)) $this->update = $update;
162
-		else $this->update = Telegram::getUpdate() !== false ? Telegram::getUpdate() : null;
163
+		if (!empty($update)) {
164
+		    $this->update = $update;
165
+		} else {
166
+		    $this->update = Telegram::getUpdate() !== false ? Telegram::getUpdate() : null;
167
+		}
163 168
 
164 169
 		if (empty($this->update)) {
165 170
 			TelegramLog::error(
@@ -211,7 +216,9 @@  discard block
 block discarded – undo
211 216
 		foreach ($plugins as $plugin) {
212 217
 			/** @var Plugin $plugin */
213 218
 			(new $plugin())->__execute($this, $update);
214
-			if ($this->isActive === false) break;
219
+			if ($this->isActive === false) {
220
+			    break;
221
+			}
215 222
 		}
216 223
 
217 224
 		$this->isActive = false;
Please login to merge, or discard this patch.
Indentation   +193 added lines, -193 removed lines patch added patch discarded remove patch
@@ -16,198 +16,198 @@
 block discarded – undo
16 16
 abstract class WebhookHandler extends Telegram
17 17
 {
18 18
 
19
-	/**
20
-	 * @var ?Update
21
-	 */
22
-	protected ?Update $update;
23
-
24
-	/**
25
-	 * @var array<Plugin>
26
-	 */
27
-	private array $plugins = [];
28
-
29
-	/**
30
-	 * @var bool
31
-	 */
32
-	private bool $isActive = false;
33
-
34
-	/**
35
-	 * The default configuration of the webhook.
36
-	 *
37
-	 * @var array
38
-	 */
39
-	private array $config = [
40
-		'autoload_env_file' => false,
41
-		'env_file_path' => null,
42
-	];
43
-
44
-	/**
45
-	 * Webhook constructor.
46
-	 *
47
-	 * @param string $api_key The API key of the bot. Leave it blank for autoload from .env file.
48
-	 */
49
-	public function __construct(string $api_key = '')
50
-	{
51
-		parent::__construct($api_key);
52
-
53
-		if (!Telegram::validateToken(self::getApiKey())) {
54
-			throw new InvalidBotTokenException();
55
-		}
56
-	}
57
-
58
-	/**
59
-	 * Initialize the receiver.
60
-	 *
61
-	 * @return void
62
-	 */
63
-	public function init(): void
64
-	{
65
-		$this->config['env_file_path'] = $_SERVER['DOCUMENT_ROOT'] . '/.env';
66
-	}
67
-
68
-	/**
69
-	 * Add a plugin to the receiver
70
-	 *
71
-	 * @param array<Plugin> $plugins
72
-	 */
73
-	public function addPlugin(array $plugins): void
74
-	{
75
-		foreach ($plugins as $plugin) {
76
-			if (!is_subclass_of($plugin, Plugin::class)) {
77
-				throw new \RuntimeException(
78
-					sprintf('The plugin %s must be an instance of %s', get_class($plugin), Plugin::class)
79
-				);
80
-			}
81
-			$this->plugins[] = $plugin;
82
-		}
83
-	}
84
-
85
-	/**
86
-	 * Match the update with the given plugins
87
-	 *
88
-	 * @param array<Plugin> $plugins
89
-	 * @param ?Update $update The update to match
90
-	 * @return void
91
-	 */
92
-	public function loadPluginsWith(array $plugins, Update $update = null): void
93
-	{
94
-		$update = $update ?? ($this->update ?? Telegram::getUpdate());
95
-
96
-		foreach ($plugins as $plugin) {
97
-			if (!is_subclass_of($plugin, Plugin::class)) {
98
-				throw new \InvalidArgumentException(
99
-					sprintf('The plugin %s must be an instance of %s', get_class($plugin), Plugin::class)
100
-				);
101
-			}
102
-		}
103
-
104
-		if ($update instanceof Update) {
105
-			$this->spreadUpdateWith($update, $plugins);
106
-		}
107
-	}
108
-
109
-	/**
110
-	 * Match the message to the plugins
111
-	 *
112
-	 * @param ?Update $update The update to match
113
-	 * @return void
114
-	 */
115
-	public function loadPlugins(Update $update = null): void
116
-	{
117
-		$update = $update ?? ($this->update ?? Telegram::getUpdate());
118
-		$this->loadPluginsWith($this->plugins, $update);
119
-	}
120
-
121
-	/**
122
-	 * Load the environment's
123
-	 *
124
-	 * @param string $path
125
-	 * @retrun void
126
-	 */
127
-	public function loadFileOfEnv(string $path): void
128
-	{
129
-		DotEnv::load($path);
130
-	}
131
-
132
-	/**
133
-	 * Update the configuration
134
-	 *
135
-	 * @param array $configuration
136
-	 * @return void
137
-	 */
138
-	public function updateConfiguration(array $configuration): void
139
-	{
140
-		$this->config = array_merge($this->config, $configuration);
141
-	}
142
-
143
-	/**
144
-	 * Resolve the request.
145
-	 *
146
-	 * @param ?Update $update The custom to work with
147
-	 * @param array $config The configuration of the receiver
148
-	 *
149
-	 * @retrun void
150
-	 */
151
-	public function resolve(Update $update = null, array $config = []): void
152
-	{
153
-		$method = '__process';
154
-		if (!method_exists($this, $method)) {
155
-			throw new \RuntimeException(sprintf('The method %s does not exist', $method));
156
-		}
157
-
158
-		if (is_array($config)) $this->updateConfiguration($config);
159
-
160
-		if (!empty($update)) $this->update = $update;
161
-		else $this->update = Telegram::getUpdate() !== false ? Telegram::getUpdate() : null;
162
-
163
-		if (empty($this->update)) {
164
-			TelegramLog::error(
165
-				'The update is empty, the request is not processed'
166
-			);
167
-			return;
168
-		}
169
-
170
-		putenv('TG_CURRENT_UPDATE=' . $this->update->getRawData(false));
171
-
172
-		$this->$method($this->update);
173
-	}
174
-
175
-	/**
176
-	 * This function will get update and spread it to the plugins
177
-	 *
178
-	 * @param Update $update
179
-	 * @param array<Plugin> $plugins
180
-	 * @return void
181
-	 */
182
-	private function spreadUpdateWith(Update $update, array $plugins): void
183
-	{
184
-		$this->isActive = true;
185
-
186
-		foreach ($plugins as $plugin) {
187
-			/** @var Plugin $plugin */
188
-			(new $plugin())->__execute($this, $update);
189
-			if ($this->isActive === false) break;
190
-		}
191
-
192
-		$this->isActive = false;
193
-	}
194
-
195
-	/**
196
-	 * Kill the speeding process
197
-	 *
198
-	 * @return void
199
-	 */
200
-	public function kill(): void
201
-	{
202
-		$this->isActive = false;
203
-	}
204
-
205
-	/**
206
-	 * Use this method on the webhook class to get the updates
207
-	 *
208
-	 * @param Update $update
209
-	 * @return void
210
-	 */
211
-	abstract public function __process(Update $update): void;
19
+    /**
20
+     * @var ?Update
21
+     */
22
+    protected ?Update $update;
23
+
24
+    /**
25
+     * @var array<Plugin>
26
+     */
27
+    private array $plugins = [];
28
+
29
+    /**
30
+     * @var bool
31
+     */
32
+    private bool $isActive = false;
33
+
34
+    /**
35
+     * The default configuration of the webhook.
36
+     *
37
+     * @var array
38
+     */
39
+    private array $config = [
40
+        'autoload_env_file' => false,
41
+        'env_file_path' => null,
42
+    ];
43
+
44
+    /**
45
+     * Webhook constructor.
46
+     *
47
+     * @param string $api_key The API key of the bot. Leave it blank for autoload from .env file.
48
+     */
49
+    public function __construct(string $api_key = '')
50
+    {
51
+        parent::__construct($api_key);
52
+
53
+        if (!Telegram::validateToken(self::getApiKey())) {
54
+            throw new InvalidBotTokenException();
55
+        }
56
+    }
57
+
58
+    /**
59
+     * Initialize the receiver.
60
+     *
61
+     * @return void
62
+     */
63
+    public function init(): void
64
+    {
65
+        $this->config['env_file_path'] = $_SERVER['DOCUMENT_ROOT'] . '/.env';
66
+    }
67
+
68
+    /**
69
+     * Add a plugin to the receiver
70
+     *
71
+     * @param array<Plugin> $plugins
72
+     */
73
+    public function addPlugin(array $plugins): void
74
+    {
75
+        foreach ($plugins as $plugin) {
76
+            if (!is_subclass_of($plugin, Plugin::class)) {
77
+                throw new \RuntimeException(
78
+                    sprintf('The plugin %s must be an instance of %s', get_class($plugin), Plugin::class)
79
+                );
80
+            }
81
+            $this->plugins[] = $plugin;
82
+        }
83
+    }
84
+
85
+    /**
86
+     * Match the update with the given plugins
87
+     *
88
+     * @param array<Plugin> $plugins
89
+     * @param ?Update $update The update to match
90
+     * @return void
91
+     */
92
+    public function loadPluginsWith(array $plugins, Update $update = null): void
93
+    {
94
+        $update = $update ?? ($this->update ?? Telegram::getUpdate());
95
+
96
+        foreach ($plugins as $plugin) {
97
+            if (!is_subclass_of($plugin, Plugin::class)) {
98
+                throw new \InvalidArgumentException(
99
+                    sprintf('The plugin %s must be an instance of %s', get_class($plugin), Plugin::class)
100
+                );
101
+            }
102
+        }
103
+
104
+        if ($update instanceof Update) {
105
+            $this->spreadUpdateWith($update, $plugins);
106
+        }
107
+    }
108
+
109
+    /**
110
+     * Match the message to the plugins
111
+     *
112
+     * @param ?Update $update The update to match
113
+     * @return void
114
+     */
115
+    public function loadPlugins(Update $update = null): void
116
+    {
117
+        $update = $update ?? ($this->update ?? Telegram::getUpdate());
118
+        $this->loadPluginsWith($this->plugins, $update);
119
+    }
120
+
121
+    /**
122
+     * Load the environment's
123
+     *
124
+     * @param string $path
125
+     * @retrun void
126
+     */
127
+    public function loadFileOfEnv(string $path): void
128
+    {
129
+        DotEnv::load($path);
130
+    }
131
+
132
+    /**
133
+     * Update the configuration
134
+     *
135
+     * @param array $configuration
136
+     * @return void
137
+     */
138
+    public function updateConfiguration(array $configuration): void
139
+    {
140
+        $this->config = array_merge($this->config, $configuration);
141
+    }
142
+
143
+    /**
144
+     * Resolve the request.
145
+     *
146
+     * @param ?Update $update The custom to work with
147
+     * @param array $config The configuration of the receiver
148
+     *
149
+     * @retrun void
150
+     */
151
+    public function resolve(Update $update = null, array $config = []): void
152
+    {
153
+        $method = '__process';
154
+        if (!method_exists($this, $method)) {
155
+            throw new \RuntimeException(sprintf('The method %s does not exist', $method));
156
+        }
157
+
158
+        if (is_array($config)) $this->updateConfiguration($config);
159
+
160
+        if (!empty($update)) $this->update = $update;
161
+        else $this->update = Telegram::getUpdate() !== false ? Telegram::getUpdate() : null;
162
+
163
+        if (empty($this->update)) {
164
+            TelegramLog::error(
165
+                'The update is empty, the request is not processed'
166
+            );
167
+            return;
168
+        }
169
+
170
+        putenv('TG_CURRENT_UPDATE=' . $this->update->getRawData(false));
171
+
172
+        $this->$method($this->update);
173
+    }
174
+
175
+    /**
176
+     * This function will get update and spread it to the plugins
177
+     *
178
+     * @param Update $update
179
+     * @param array<Plugin> $plugins
180
+     * @return void
181
+     */
182
+    private function spreadUpdateWith(Update $update, array $plugins): void
183
+    {
184
+        $this->isActive = true;
185
+
186
+        foreach ($plugins as $plugin) {
187
+            /** @var Plugin $plugin */
188
+            (new $plugin())->__execute($this, $update);
189
+            if ($this->isActive === false) break;
190
+        }
191
+
192
+        $this->isActive = false;
193
+    }
194
+
195
+    /**
196
+     * Kill the speeding process
197
+     *
198
+     * @return void
199
+     */
200
+    public function kill(): void
201
+    {
202
+        $this->isActive = false;
203
+    }
204
+
205
+    /**
206
+     * Use this method on the webhook class to get the updates
207
+     *
208
+     * @param Update $update
209
+     * @return void
210
+     */
211
+    abstract public function __process(Update $update): void;
212 212
 
213 213
 }
214 214
\ No newline at end of file
Please login to merge, or discard this patch.
src/lib/Entities/InlineKeyboardButton.php 1 patch
Indentation   +37 added lines, -37 removed lines patch added patch discarded remove patch
@@ -35,49 +35,49 @@
 block discarded – undo
35 35
 class InlineKeyboardButton extends KeyboardButton
36 36
 {
37 37
 
38
-	/**
39
-	 * Creates instance of InlineKeyboardButton
40
-	 *
41
-	 * @param string $string
42
-	 * @return InlineKeyboardButton
43
-	 */
44
-	public static function make(string $string): InlineKeyboardButton
45
-	{
46
-		return new self($string);
47
-	}
38
+    /**
39
+     * Creates instance of InlineKeyboardButton
40
+     *
41
+     * @param string $string
42
+     * @return InlineKeyboardButton
43
+     */
44
+    public static function make(string $string): InlineKeyboardButton
45
+    {
46
+        return new self($string);
47
+    }
48 48
 
49
-	/**
50
-	 * @param string $data
51
-	 * @return $this
52
-	 */
53
-	public function CallbackData(string $data): InlineKeyboardButton
54
-	{
55
-		$this->raw_data['callback_data'] = $data;
49
+    /**
50
+     * @param string $data
51
+     * @return $this
52
+     */
53
+    public function CallbackData(string $data): InlineKeyboardButton
54
+    {
55
+        $this->raw_data['callback_data'] = $data;
56 56
 
57
-		return $this;
58
-	}
57
+        return $this;
58
+    }
59 59
 
60
-	/**
61
-	 * @param string $data
62
-	 * @return $this
63
-	 */
64
-	public function Url(string $data): InlineKeyboardButton
65
-	{
66
-		$this->raw_data['url'] = $data;
60
+    /**
61
+     * @param string $data
62
+     * @return $this
63
+     */
64
+    public function Url(string $data): InlineKeyboardButton
65
+    {
66
+        $this->raw_data['url'] = $data;
67 67
 
68
-		return $this;
69
-	}
68
+        return $this;
69
+    }
70 70
 
71
-	/**
72
-	 * @param string $url
73
-	 * @return $this
74
-	 */
75
-	public function WebApp(string $url): KeyboardButton
76
-	{
77
-		$this->raw_data['web_app'] = new WebAppInfo(['url' => $url]);
71
+    /**
72
+     * @param string $url
73
+     * @return $this
74
+     */
75
+    public function WebApp(string $url): KeyboardButton
76
+    {
77
+        $this->raw_data['web_app'] = new WebAppInfo(['url' => $url]);
78 78
 
79
-		return $this;
80
-	}
79
+        return $this;
80
+    }
81 81
 
82 82
     /**
83 83
      * Check if the passed data array could be an InlineKeyboardButton.
Please login to merge, or discard this patch.
src/lib/Util/Common.php 1 patch
Indentation   +49 added lines, -49 removed lines patch added patch discarded remove patch
@@ -12,63 +12,63 @@
 block discarded – undo
12 12
 class Common
13 13
 {
14 14
 
15
-	/**
16
-	 * Validate the given string is JSON or not
17
-	 *
18
-	 * @param ?string $string
19
-	 * @return bool
20
-	 */
21
-	public static function isJson(?string $string): bool
22
-	{
23
-		if (!is_string($string)) {
24
-			return false;
25
-		}
15
+    /**
16
+     * Validate the given string is JSON or not
17
+     *
18
+     * @param ?string $string
19
+     * @return bool
20
+     */
21
+    public static function isJson(?string $string): bool
22
+    {
23
+        if (!is_string($string)) {
24
+            return false;
25
+        }
26 26
 
27
-		json_decode($string);
27
+        json_decode($string);
28 28
 
29
-		return json_last_error() === JSON_ERROR_NONE;
30
-	}
29
+        return json_last_error() === JSON_ERROR_NONE;
30
+    }
31 31
 
32
-	/**
33
-	 * Check string is a url encoded string or not
34
-	 *
35
-	 * @param ?string $string
36
-	 * @return bool
37
-	 */
38
-	public static function isUrlEncode(?string $string): bool
39
-	{
40
-		if (!is_string($string)) {
41
-			return false;
42
-		}
32
+    /**
33
+     * Check string is a url encoded string or not
34
+     *
35
+     * @param ?string $string
36
+     * @return bool
37
+     */
38
+    public static function isUrlEncode(?string $string): bool
39
+    {
40
+        if (!is_string($string)) {
41
+            return false;
42
+        }
43 43
 
44
-		return preg_match('/%[0-9A-F]{2}/i', $string);
45
-	}
44
+        return preg_match('/%[0-9A-F]{2}/i', $string);
45
+    }
46 46
 
47
-	/**
48
-	 * Convert url encoded string to array
49
-	 *
50
-	 * @param string $string
51
-	 * @return array
52
-	 */
53
-	public static function urlDecode(string $string): array
54
-	{
55
-		$raw_data = explode('&', urldecode($string));
56
-		$data = [];
47
+    /**
48
+     * Convert url encoded string to array
49
+     *
50
+     * @param string $string
51
+     * @return array
52
+     */
53
+    public static function urlDecode(string $string): array
54
+    {
55
+        $raw_data = explode('&', urldecode($string));
56
+        $data = [];
57 57
 
58
-		foreach ($raw_data as $row) {
59
-			[$key, $value] = explode('=', $row);
58
+        foreach ($raw_data as $row) {
59
+            [$key, $value] = explode('=', $row);
60 60
 
61
-			if (self::isUrlEncode($value)) {
62
-				$value = urldecode($value);
63
-				if (self::isJson($value)) {
64
-					$value = json_decode($value, true);
65
-				}
66
-			}
61
+            if (self::isUrlEncode($value)) {
62
+                $value = urldecode($value);
63
+                if (self::isJson($value)) {
64
+                    $value = json_decode($value, true);
65
+                }
66
+            }
67 67
 
68
-			$data[$key] = $value;
69
-		}
68
+            $data[$key] = $value;
69
+        }
70 70
 
71
-		return $data;
72
-	}
71
+        return $data;
72
+    }
73 73
 
74 74
 }
75 75
\ No newline at end of file
Please login to merge, or discard this patch.
src/lib/Entities/ChatMemberUpdated.php 1 patch
Indentation   +13 added lines, -13 removed lines patch added patch discarded remove patch
@@ -23,18 +23,18 @@
 block discarded – undo
23 23
 class ChatMemberUpdated extends Entity
24 24
 {
25 25
 
26
-	/**
27
-	 * {@inheritdoc}
28
-	 */
29
-	protected function subEntities(): array
30
-	{
31
-		return [
32
-			'chat' => Chat::class,
33
-			'from' => User::class,
34
-			'old_chat_member' => ChatMemberFactory::class,
35
-			'new_chat_member' => ChatMemberFactory::class,
36
-			'invite_link' => ChatInviteLink::class,
37
-		];
38
-	}
26
+    /**
27
+     * {@inheritdoc}
28
+     */
29
+    protected function subEntities(): array
30
+    {
31
+        return [
32
+            'chat' => Chat::class,
33
+            'from' => User::class,
34
+            'old_chat_member' => ChatMemberFactory::class,
35
+            'new_chat_member' => ChatMemberFactory::class,
36
+            'invite_link' => ChatInviteLink::class,
37
+        ];
38
+    }
39 39
 
40 40
 }
Please login to merge, or discard this patch.
src/lib/Entities/UserProfilePhotos.php 2 patches
Indentation   +31 added lines, -31 removed lines patch added patch discarded remove patch
@@ -15,36 +15,36 @@
 block discarded – undo
15 15
 class UserProfilePhotos extends Entity
16 16
 {
17 17
 
18
-	/**
19
-	 * {@inheritdoc}
20
-	 */
21
-	protected function subEntities(): array
22
-	{
23
-		return [
24
-			'photos' => PhotoSize::class,
25
-		];
26
-	}
27
-
28
-	/**
29
-	 * Requested profile pictures (in up to 4 sizes each)
30
-	 *
31
-	 * This method overrides the default getPhotos method and returns a nice array
32
-	 *
33
-	 * @return PhotoSize[][]
34
-	 */
35
-	public function getPhotos(): array
36
-	{
37
-		$all_photos = [];
38
-
39
-		if ($these_photos = $this->getProperty('photos')) {
40
-			foreach ($these_photos as $photos) {
41
-				$all_photos[] = array_map(function ($photo) {
42
-					return new PhotoSize($photo);
43
-				}, $photos);
44
-			}
45
-		}
46
-
47
-		return $all_photos;
48
-	}
18
+    /**
19
+     * {@inheritdoc}
20
+     */
21
+    protected function subEntities(): array
22
+    {
23
+        return [
24
+            'photos' => PhotoSize::class,
25
+        ];
26
+    }
27
+
28
+    /**
29
+     * Requested profile pictures (in up to 4 sizes each)
30
+     *
31
+     * This method overrides the default getPhotos method and returns a nice array
32
+     *
33
+     * @return PhotoSize[][]
34
+     */
35
+    public function getPhotos(): array
36
+    {
37
+        $all_photos = [];
38
+
39
+        if ($these_photos = $this->getProperty('photos')) {
40
+            foreach ($these_photos as $photos) {
41
+                $all_photos[] = array_map(function ($photo) {
42
+                    return new PhotoSize($photo);
43
+                }, $photos);
44
+            }
45
+        }
46
+
47
+        return $all_photos;
48
+    }
49 49
 
50 50
 }
Please login to merge, or discard this patch.
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -38,7 +38,7 @@
 block discarded – undo
38 38
 
39 39
 		if ($these_photos = $this->getProperty('photos')) {
40 40
 			foreach ($these_photos as $photos) {
41
-				$all_photos[] = array_map(function ($photo) {
41
+				$all_photos[] = array_map(function($photo) {
42 42
 					return new PhotoSize($photo);
43 43
 				}, $photos);
44 44
 			}
Please login to merge, or discard this patch.
src/lib/Entities/VideoChatParticipantsInvited.php 1 patch
Indentation   +9 added lines, -9 removed lines patch added patch discarded remove patch
@@ -14,14 +14,14 @@
 block discarded – undo
14 14
 class VideoChatParticipantsInvited extends Entity
15 15
 {
16 16
 
17
-	/**
18
-	 * {@inheritdoc}
19
-	 */
20
-	protected function subEntities(): array
21
-	{
22
-		return [
23
-			'users' => [User::class],
24
-		];
25
-	}
17
+    /**
18
+     * {@inheritdoc}
19
+     */
20
+    protected function subEntities(): array
21
+    {
22
+        return [
23
+            'users' => [User::class],
24
+        ];
25
+    }
26 26
 
27 27
 }
Please login to merge, or discard this patch.