Skip to content

Commit e3c4769

Browse files
irazasyedgithub-actions[bot]
authored andcommitted
Fix styling
1 parent 177b5b8 commit e3c4769

11 files changed

+74
-90
lines changed

src/Telegram.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ class Telegram
2525

2626
public function __construct(
2727
?string $token = null,
28-
HttpClient $httpClient = new HttpClient(),
28+
HttpClient $httpClient = new HttpClient,
2929
string $apiBaseUri = 'https://api.telegram.org'
3030
) {
3131
$this->token = $token;
@@ -117,7 +117,7 @@ public function sendMessage(array $params): ?ResponseInterface
117117
*/
118118
public function sendFile(array $params, string|array $type, bool $multipart = false): ?ResponseInterface
119119
{
120-
return $this->sendRequest('send'.Str::studly((array)$type[0]), $params, $multipart);
120+
return $this->sendRequest('send'.Str::studly((array) $type[0]), $params, $multipart);
121121
}
122122

123123
/**

src/TelegramChannel.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ public function send(mixed $notifiable, Notification $notification): ?array
3232
$message = TelegramMessage::create($message);
3333
}
3434

35-
if (!$message->canSend()) {
35+
if (! $message->canSend()) {
3636
return null;
3737
}
3838

src/TelegramFile.php

Lines changed: 8 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,10 @@
44

55
use Illuminate\Support\Facades\View;
66
use NotificationChannels\Telegram\Contracts\TelegramSenderContract;
7+
use NotificationChannels\Telegram\Enums\ParseMode;
78
use NotificationChannels\Telegram\Exceptions\CouldNotSendNotification;
89
use Psr\Http\Message\ResponseInterface;
910
use Psr\Http\Message\StreamInterface;
10-
use NotificationChannels\Telegram\Enums\ParseMode;
1111

1212
/**
1313
* Class TelegramFile.
@@ -47,8 +47,6 @@ public function content(string $content): self
4747
* Generic method to attach files of any type based on API.
4848
*
4949
* @param resource|StreamInterface|string $file
50-
* @param string $type
51-
* @param string|null $filename
5250
* @return $this
5351
*/
5452
public function file(mixed $file, string $type, ?string $filename = null): self
@@ -75,7 +73,7 @@ public function file(mixed $file, string $type, ?string $filename = null): self
7573

7674
/**
7775
* Attach an image.
78-
* @param string $file
76+
*
7977
* @return $this
8078
*/
8179
public function photo(string $file): self
@@ -85,7 +83,7 @@ public function photo(string $file): self
8583

8684
/**
8785
* Attach an audio file.
88-
* @param string $file
86+
*
8987
* @return $this
9088
*/
9189
public function audio(string $file): self
@@ -95,8 +93,7 @@ public function audio(string $file): self
9593

9694
/**
9795
* Attach a document or any file as document.
98-
* @param string $file
99-
* @param string|null $filename
96+
*
10097
* @return $this
10198
*/
10299
public function document(string $file, ?string $filename = null): self
@@ -106,7 +103,7 @@ public function document(string $file, ?string $filename = null): self
106103

107104
/**
108105
* Attach a video file.
109-
* @param string $file
106+
*
110107
* @return $this
111108
*/
112109
public function video(string $file): self
@@ -116,7 +113,7 @@ public function video(string $file): self
116113

117114
/**
118115
* Attach an animation file.
119-
* @param string $file
116+
*
120117
* @return $this
121118
*/
122119
public function animation(string $file): self
@@ -126,7 +123,7 @@ public function animation(string $file): self
126123

127124
/**
128125
* Attach a voice file.
129-
* @param string $file
126+
*
130127
* @return $this
131128
*/
132129
public function voice(string $file): self
@@ -136,7 +133,7 @@ public function voice(string $file): self
136133

137134
/**
138135
* Attach a video note file.
139-
* @param string $file
136+
*
140137
* @return $this
141138
*/
142139
public function videoNote(string $file): self

src/TelegramMessage.php

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,13 +8,14 @@
88
use Illuminate\Support\Facades\View;
99
use JsonException;
1010
use NotificationChannels\Telegram\Contracts\TelegramSenderContract;
11-
use NotificationChannels\Telegram\Exceptions\CouldNotSendNotification;
1211
use NotificationChannels\Telegram\Enums\ParseMode;
12+
use NotificationChannels\Telegram\Exceptions\CouldNotSendNotification;
1313
use Psr\Http\Message\ResponseInterface;
1414

1515
final class TelegramMessage extends TelegramBase implements TelegramSenderContract
1616
{
1717
private const DEFAULT_CHUNK_SIZE = 4096;
18+
1819
private const CHUNK_SEPARATOR = '%#TGMSG#%';
1920

2021
public function __construct(
@@ -84,9 +85,10 @@ public function shouldChunk(): bool
8485
}
8586

8687
/**
88+
* @return array<int, array<string, mixed>>|ResponseInterface|null
89+
*
8790
* @throws CouldNotSendNotification
8891
* @throws JsonException
89-
* @return array<int, array<string, mixed>>|ResponseInterface|null
9092
*/
9193
public function send(): array|ResponseInterface|null
9294
{
@@ -96,8 +98,9 @@ public function send(): array|ResponseInterface|null
9698
}
9799

98100
/**
99-
* @param array<string, mixed> $params
101+
* @param array<string, mixed> $params
100102
* @return array<int, array<string, mixed>>
103+
*
101104
* @throws CouldNotSendNotification
102105
* @throws JsonException
103106
*/

src/TelegramUpdates.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ public function __construct(protected array $payload = []) {}
1111

1212
public static function create(): self
1313
{
14-
return new self();
14+
return new self;
1515
}
1616

1717
/**

src/Traits/HasSharedLogic.php

Lines changed: 31 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -41,8 +41,7 @@ trait HasSharedLogic
4141
/**
4242
* Set the recipient's Chat ID.
4343
*
44-
* @param int|string $chatId The unique identifier for the target chat
45-
* @return static
44+
* @param int|string $chatId The unique identifier for the target chat
4645
*/
4746
public function to(int|string $chatId): static
4847
{
@@ -54,9 +53,9 @@ public function to(int|string $chatId): static
5453
/**
5554
* Set the keyboard markup for the message.
5655
*
57-
* @param array<string, mixed> $markup The keyboard markup array
56+
* @param array<string, mixed> $markup The keyboard markup array
57+
*
5858
* @throws JsonException When JSON encoding fails
59-
* @return static
6059
*/
6160
public function keyboardMarkup(array $markup): static
6261
{
@@ -67,8 +66,6 @@ public function keyboardMarkup(array $markup): static
6766

6867
/**
6968
* Unset parse mode of the message.
70-
*
71-
* @return static
7269
*/
7370
public function normal(): static
7471
{
@@ -80,8 +77,7 @@ public function normal(): static
8077
/**
8178
* Set the parse mode of the message.
8279
*
83-
* @param ParseMode|null $mode The parse mode to use
84-
* @return static
80+
* @param ParseMode|null $mode The parse mode to use
8581
*/
8682
public function parseMode(?ParseMode $mode = null): static
8783
{
@@ -93,12 +89,12 @@ public function parseMode(?ParseMode $mode = null): static
9389
/**
9490
* Add a normal keyboard button.
9591
*
96-
* @param string $text The text to display on the button
97-
* @param int $columns Number of columns for button layout
98-
* @param bool $requestContact Whether to request user's contact
99-
* @param bool $requestLocation Whether to request user's location
92+
* @param string $text The text to display on the button
93+
* @param int $columns Number of columns for button layout
94+
* @param bool $requestContact Whether to request user's contact
95+
* @param bool $requestLocation Whether to request user's location
96+
*
10097
* @throws JsonException When JSON encoding fails
101-
* @return static
10298
*/
10399
public function keyboard(
104100
string $text,
@@ -124,11 +120,11 @@ public function keyboard(
124120
/**
125121
* Add an inline button with URL.
126122
*
127-
* @param string $text The text to display on the button
128-
* @param string $url The URL to open when button is pressed
129-
* @param int $columns Number of columns for button layout
123+
* @param string $text The text to display on the button
124+
* @param string $url The URL to open when button is pressed
125+
* @param int $columns Number of columns for button layout
126+
*
130127
* @throws JsonException When JSON encoding fails
131-
* @return static
132128
*/
133129
public function button(string $text, string $url, int $columns = 2): static
134130
{
@@ -140,11 +136,11 @@ public function button(string $text, string $url, int $columns = 2): static
140136
/**
141137
* Add an inline button with callback data.
142138
*
143-
* @param string $text The text to display on the button
144-
* @param string $callbackData The data to send when button is pressed
145-
* @param int $columns Number of columns for button layout
139+
* @param string $text The text to display on the button
140+
* @param string $callbackData The data to send when button is pressed
141+
* @param int $columns Number of columns for button layout
142+
*
146143
* @throws JsonException When JSON encoding fails
147-
* @return static
148144
*/
149145
public function buttonWithCallback(string $text, string $callbackData, int $columns = 2): static
150146
{
@@ -159,11 +155,11 @@ public function buttonWithCallback(string $text, string $callbackData, int $colu
159155
/**
160156
* Add an inline button with web app.
161157
*
162-
* @param string $text The text to display on the button
163-
* @param string $url The URL of the Web App to open
164-
* @param int $columns Number of columns for button layout
158+
* @param string $text The text to display on the button
159+
* @param string $url The URL of the Web App to open
160+
* @param int $columns Number of columns for button layout
161+
*
165162
* @throws JsonException When JSON encoding fails
166-
* @return static
167163
*/
168164
public function buttonWithWebApp(string $text, string $url, int $columns = 2): static
169165
{
@@ -178,8 +174,7 @@ public function buttonWithWebApp(string $text, string $url, int $columns = 2): s
178174
/**
179175
* Send the message silently. Users will receive a notification with no sound.
180176
*
181-
* @param bool $disable Whether to disable the notification sound
182-
* @return static
177+
* @param bool $disable Whether to disable the notification sound
183178
*/
184179
public function disableNotification(bool $disable = true): static
185180
{
@@ -191,8 +186,7 @@ public function disableNotification(bool $disable = true): static
191186
/**
192187
* Set the Bot Token. Overrides default bot token with the given value for this notification.
193188
*
194-
* @param string $token The bot token to use
195-
* @return static
189+
* @param string $token The bot token to use
196190
*/
197191
public function token(string $token): static
198192
{
@@ -203,8 +197,6 @@ public function token(string $token): static
203197

204198
/**
205199
* Determine if bot token is given for this notification.
206-
*
207-
* @return bool
208200
*/
209201
public function hasToken(): bool
210202
{
@@ -214,8 +206,7 @@ public function hasToken(): bool
214206
/**
215207
* Set additional options to pass to sendMessage method.
216208
*
217-
* @param array<string, mixed> $options Additional options
218-
* @return static
209+
* @param array<string, mixed> $options Additional options
219210
*/
220211
public function options(array $options): static
221212
{
@@ -231,8 +222,7 @@ public function options(array $options): static
231222
* which will be invoked if an exception occurs during the
232223
* notification process. The callback must be a valid Closure.
233224
*
234-
* @param Closure $callback The closure that will handle exceptions.
235-
* @return self
225+
* @param Closure $callback The closure that will handle exceptions.
236226
*/
237227
public function onError(Closure $callback): self
238228
{
@@ -244,20 +234,17 @@ public function onError(Closure $callback): self
244234
/**
245235
* Set a condition for sending the message.
246236
*
247-
* @param bool|callable $condition The condition to evaluate
248-
* @return static
237+
* @param bool|callable $condition The condition to evaluate
249238
*/
250239
public function sendWhen(bool|callable $condition): static
251240
{
252-
$this->sendCondition = $this->when($condition, fn() => true, fn() => false);
241+
$this->sendCondition = $this->when($condition, fn () => true, fn () => false);
253242

254243
return $this;
255244
}
256245

257246
/**
258247
* Determine if the message can be sent based on the condition.
259-
*
260-
* @return bool
261248
*/
262249
public function canSend(): bool
263250
{
@@ -266,18 +253,16 @@ public function canSend(): bool
266253

267254
/**
268255
* Determine if chat id is not given.
269-
*
270-
* @return bool
271256
*/
272257
public function toNotGiven(): bool
273258
{
274-
return !isset($this->payload['chat_id']);
259+
return ! isset($this->payload['chat_id']);
275260
}
276261

277262
/**
278263
* Get payload value for given key.
279264
*
280-
* @param string $key The key to retrieve from payload
265+
* @param string $key The key to retrieve from payload
281266
* @return mixed The value from payload or null if not found
282267
*/
283268
public function getPayloadValue(string $key): mixed
@@ -308,9 +293,9 @@ public function jsonSerialize(): array
308293
/**
309294
* Update the inline keyboard markup.
310295
*
311-
* @param int $columns Number of columns for button layout
296+
* @param int $columns Number of columns for button layout
297+
*
312298
* @throws JsonException When JSON encoding fails
313-
* @return static
314299
*/
315300
private function updateInlineKeyboard(int $columns): static
316301
{

tests/Feature/TelegramChannelTest.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,8 @@
66
use NotificationChannels\Telegram\Tests\TestSupport\TestNotification;
77

88
it('can send a message', function () {
9-
$notifiable = new TestNotifiable();
10-
$notification = new TestNotification();
9+
$notifiable = new TestNotifiable;
10+
$notification = new TestNotification;
1111

1212
$expectedResponse = ['ok' => true, 'result' => ['message_id' => 123, 'chat' => ['id' => 12345]]];
1313
$actualResponse = $this->sendMockNotification('sendMessage', $notifiable, $notification, $expectedResponse);
@@ -19,8 +19,8 @@
1919
self::expectException($exception_class = CouldNotSendNotification::class);
2020
self::expectExceptionMessage($exception_message = 'Some exception');
2121

22-
$notifiable = new TestNotifiable();
23-
$notification = new TestNotification();
22+
$notifiable = new TestNotifiable;
23+
$notification = new TestNotification;
2424

2525
$payload = $notification->toTelegram($notifiable)->toArray();
2626

0 commit comments

Comments
 (0)