From f32e64721488922acf9ae698f1395eab8d1c0902 Mon Sep 17 00:00:00 2001 From: Rias Date: Tue, 23 Jan 2018 20:42:44 +0000 Subject: [PATCH] Apply fixes from StyleCI --- src/TelegramNotificationChannel.php | 25 +++++++++---------- src/config.php | 7 +++--- src/exceptions/CouldNotSendNotification.php | 6 ++++- src/models/Settings.php | 12 ++++----- src/models/Telegram.php | 5 ++-- src/models/TelegramChannel.php | 4 +-- src/models/TelegramMessage.php | 6 ++++- .../en/telegram-notification-channel.php | 7 +++--- 8 files changed, 41 insertions(+), 31 deletions(-) diff --git a/src/TelegramNotificationChannel.php b/src/TelegramNotificationChannel.php index f5f81ab..173a2df 100644 --- a/src/TelegramNotificationChannel.php +++ b/src/TelegramNotificationChannel.php @@ -1,24 +1,22 @@ view->renderTemplate( 'telegram-notification-channel/settings', [ - 'settings' => $this->getSettings() + 'settings' => $this->getSettings(), ] ); } diff --git a/src/config.php b/src/config.php index 68aa3ba..5612e6f 100644 --- a/src/config.php +++ b/src/config.php @@ -1,15 +1,16 @@ getResponse()->getBody())) { $description = $result->description ?: $description; } + return new static("Telegram responded with an error `{$statusCode} - {$description}`"); } + /** * Thrown when there's no bot token provided. * @@ -33,6 +35,7 @@ public static function telegramBotTokenNotProvided($message) { return new static($message); } + /** * Thrown when we're unable to communicate with Telegram. * @@ -42,6 +45,7 @@ public static function couldNotCommunicateWithTelegram() { return new static('The communication with Telegram failed.'); } + /** * Thrown when there is no chat id provided. * @@ -51,4 +55,4 @@ public static function chatIdNotProvided() { return new static('Telegram notification chat ID was not provided. Please refer usage docs.'); } -} \ No newline at end of file +} diff --git a/src/models/Settings.php b/src/models/Settings.php index 5976ea4..bd87757 100644 --- a/src/models/Settings.php +++ b/src/models/Settings.php @@ -1,22 +1,22 @@ toArray(); $this->telegram->sendMessage($params); } -} \ No newline at end of file +} diff --git a/src/models/TelegramMessage.php b/src/models/TelegramMessage.php index 1b66249..6283e0f 100644 --- a/src/models/TelegramMessage.php +++ b/src/models/TelegramMessage.php @@ -45,6 +45,7 @@ public function __construct($content = '') public function to($chatId) { $this->payload['chat_id'] = $chatId; + return $this; } @@ -58,6 +59,7 @@ public function to($chatId) public function content($content) { $this->payload['text'] = $content; + return $this; } @@ -74,6 +76,7 @@ public function button($text, $url) $this->buttons[] = compact('text', 'url'); $replyMarkup['inline_keyboard'] = array_chunk($this->buttons, 2); $this->payload['reply_markup'] = json_encode($replyMarkup); + return $this; } @@ -87,6 +90,7 @@ public function button($text, $url) public function options(array $options) { $this->payload = array_merge($this->payload, $options); + return $this; } @@ -109,4 +113,4 @@ public function toArray() { return $this->payload; } -} \ No newline at end of file +} diff --git a/src/translations/en/telegram-notification-channel.php b/src/translations/en/telegram-notification-channel.php index d898479..d461990 100644 --- a/src/translations/en/telegram-notification-channel.php +++ b/src/translations/en/telegram-notification-channel.php @@ -1,15 +1,16 @@