Skip to content

Commit

Permalink
fix code style with php cs fixer
Browse files Browse the repository at this point in the history
  • Loading branch information
tanhongit committed Oct 31, 2023
1 parent ab7824e commit e607c76
Show file tree
Hide file tree
Showing 10 changed files with 28 additions and 22 deletions.
3 changes: 1 addition & 2 deletions .php-cs-fixer.dist.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,9 @@
'array_syntax' => ['syntax' => 'short'],
'ordered_imports' => ['sort_algorithm' => 'alpha'],
'no_unused_imports' => true,
'not_operator_with_successor_space' => true,
'trailing_comma_in_multiline' => true,
'phpdoc_scalar' => true,
'unary_operator_spaces' => false,
'unary_operator_spaces' => true,
'binary_operator_spaces' => true,
'blank_line_before_statement' => [
'statements' => ['break', 'continue', 'declare', 'return', 'throw', 'try'],
Expand Down
2 changes: 1 addition & 1 deletion src/Bot.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@

use LbilTech\TelegramGitNotifier\Constants\EventConstant;
use LbilTech\TelegramGitNotifier\Interfaces\BotInterface;
use LbilTech\TelegramGitNotifier\Interfaces\EventInterface;
use LbilTech\TelegramGitNotifier\Interfaces\SettingInterface;
use LbilTech\TelegramGitNotifier\Interfaces\Structures\AppInterface;
use LbilTech\TelegramGitNotifier\Interfaces\EventInterface;
use LbilTech\TelegramGitNotifier\Models\Event;
use LbilTech\TelegramGitNotifier\Models\Setting;
use LbilTech\TelegramGitNotifier\Structures\App;
Expand Down
2 changes: 2 additions & 0 deletions src/Helpers/ConfigHelper.php
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ public function execConfig(string $string): mixed

$result = $result[$value];
}

return $result;
}

Expand All @@ -58,6 +59,7 @@ public function getTemplateData(string $partialPath, array $data = []): bool|str

$content = '';
ob_start();

try {
extract($data, EXTR_SKIP);
require_once $viewPathFile;
Expand Down
1 change: 1 addition & 0 deletions src/Interfaces/SettingInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@ public function getEndKeyboard(string $platform, ?string $parentEvent = null): a
* @see EventSettingTrait::eventHandle()
*/
public function eventHandle(?string $callback = null, ?string $platform = null, string $platformFile = null): void;

/**
* Get the platform from callback
*
Expand Down
3 changes: 2 additions & 1 deletion src/Notifier.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@
use GuzzleHttp\Client;
use LbilTech\TelegramGitNotifier\Constants\EventConstant;
use LbilTech\TelegramGitNotifier\Constants\NotificationConstant;
use LbilTech\TelegramGitNotifier\Interfaces\Structures\AppInterface;
use LbilTech\TelegramGitNotifier\Interfaces\EventInterface;
use LbilTech\TelegramGitNotifier\Interfaces\Structures\AppInterface;
use LbilTech\TelegramGitNotifier\Interfaces\Structures\NotificationInterface;
use LbilTech\TelegramGitNotifier\Models\Event;
use LbilTech\TelegramGitNotifier\Structures\App;
Expand Down Expand Up @@ -56,6 +56,7 @@ public function parseNotifyChatIds(): array
? explode(NotificationConstant::THREAD_ID_SEPARATOR, $threadIds)
: [];
}

return $chatThreadMapping;
}
}
17 changes: 9 additions & 8 deletions src/Structures/App.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,9 @@ public function setCurrentChatBotId(string $chatBotId = null): void
private function createTelegramBaseContent(): array
{
return [
'chat_id' => $this->chatBotId,
'chat_id' => $this->chatBotId,
'disable_web_page_preview' => true,
'parse_mode' => 'HTML'
'parse_mode' => 'HTML',
];
}

Expand Down Expand Up @@ -71,8 +71,8 @@ public function answerCallbackQuery(string $text = null, array $options = []): v
try {
$options = array_merge([
'callback_query_id' => $this->telegram->Callback_ID(),
'text' => $text,
'show_alert' => true
'text' => $text,
'show_alert' => true,
], $options);
$this->telegram->answerCallbackQuery($options);
} catch (Exception $e) {
Expand All @@ -86,7 +86,7 @@ public function editMessageText(
): void {
try {
$content = array_merge([
'text' => $text ?? $this->getCallbackTextMessage()
'text' => $text ?? $this->getCallbackTextMessage(),
], $this->setCallbackContentMessage($options));

$this->telegram->editMessageText($content);
Expand Down Expand Up @@ -114,10 +114,10 @@ public function getCallbackTextMessage(): string
public function setCallbackContentMessage(array $options = []): array
{
$content = [
'chat_id' => $this->telegram->Callback_ChatID(),
'message_id' => $this->telegram->MessageID(),
'chat_id' => $this->telegram->Callback_ChatID(),
'message_id' => $this->telegram->MessageID(),
'disable_web_page_preview' => true,
'parse_mode' => 'HTML',
'parse_mode' => 'HTML',
];

$content['reply_markup'] = $options['reply_markup']
Expand All @@ -135,6 +135,7 @@ public function getBotName(): ?string
public function getCommandMessage(): string
{
$text = $this->telegram->Text();

return str_replace('@' . $this->getBotName(), '', $text);
}
}
10 changes: 5 additions & 5 deletions src/Structures/Notification.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,13 +19,13 @@ public function accessDenied(
string $viewTemplate = null,
): void {
$this->telegram->sendMessage([
'chat_id' => $this->chatBotId,
'text' => view(
'chat_id' => $this->chatBotId,
'text' => view(
$viewTemplate ?? config('telegram-git-notifier.view.globals.access_denied'),
['chatId' => $chatId]
),
'disable_web_page_preview' => true,
'parse_mode' => 'HTML'
'parse_mode' => 'HTML',
]);
}

Expand Down Expand Up @@ -67,7 +67,7 @@ private function setMessage(string $typeEvent): void

$viewResult = view($viewTemplate, [
'payload' => $this->payload,
'event' => tgn_convert_event_name($typeEvent),
'event' => tgn_convert_event_name($typeEvent),
]);

if ($viewResult === null) {
Expand All @@ -87,7 +87,7 @@ public function sendNotify(string $message = null, array $options = []): bool

try {
$response = $this->client->request('POST', $url, [
'form_params' => $queryParams
'form_params' => $queryParams,
]);

if ($response->getStatusCode() === 200) {
Expand Down
4 changes: 2 additions & 2 deletions src/Trait/BotSettingTrait.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ public function setMyCommands(
?string $view = null
): void {
$this->telegram->setMyCommands([
'commands' => json_encode($menuCommand)
'commands' => json_encode($menuCommand),
]);
$this->sendMessage(
view(
Expand Down Expand Up @@ -59,7 +59,7 @@ public function settingMarkup(): array
'',
SettingConstant::SETTING_ALL_EVENTS_NOTIFY
),
]
],
];

$markup = $this->customEventMarkup($markup);
Expand Down
6 changes: 4 additions & 2 deletions src/Trait/EventSettingTrait.php
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ public function getEndKeyboard(
'📚 Menu',
'',
SettingConstant::SETTING_BACK_TO_MAIN_MENU
)
),
];
}

Expand Down Expand Up @@ -149,6 +149,7 @@ public function sendSettingEventMessage(
),
['reply_markup' => $this->eventMarkup(null, $platform)]
);

return true;
}

Expand All @@ -164,7 +165,7 @@ public function getEventFromCallback(?string $callback): string
return str_replace([
EventConstant::EVENT_PREFIX,
EventConstant::GITHUB_EVENT_SEPARATOR,
EventConstant::GITLAB_EVENT_SEPARATOR
EventConstant::GITLAB_EVENT_SEPARATOR,
], '', $callback);
}

Expand All @@ -186,6 +187,7 @@ public function handleEventWithActions(
),
['reply_markup' => $this->eventMarkup($event, $platform)]
);

return true;
}

Expand Down
2 changes: 1 addition & 1 deletion src/Trait/EventTrait.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@

namespace LbilTech\TelegramGitNotifier\Trait;

use Symfony\Component\HttpFoundation\Request;
use LbilTech\TelegramGitNotifier\Constants\EventConstant;
use Symfony\Component\HttpFoundation\Request;

trait EventTrait
{
Expand Down

0 comments on commit e607c76

Please sign in to comment.