From 71d31d928c3e3c513c33512252d79dc54af4c050 Mon Sep 17 00:00:00 2001 From: antonkomarev Date: Sat, 22 Feb 2020 10:20:00 +0300 Subject: [PATCH] [Hotfix]: Code style fix --- composer.json | 1 + src/RocketChatAttachment.php | 11 +++++--- src/RocketChatMessage.php | 44 ++++++------------------------- src/RocketChatServiceProvider.php | 3 ++- src/RocketChatWebhookChannel.php | 6 +---- 5 files changed, 19 insertions(+), 46 deletions(-) diff --git a/composer.json b/composer.json index 81e7be3..aacc372 100644 --- a/composer.json +++ b/composer.json @@ -6,6 +6,7 @@ "keywords": [ "laravel", "notifications", + "notification-channel", "rocketchat", "rocket.chat", "chat" diff --git a/src/RocketChatAttachment.php b/src/RocketChatAttachment.php index c20532b..05a6f9d 100644 --- a/src/RocketChatAttachment.php +++ b/src/RocketChatAttachment.php @@ -4,7 +4,10 @@ namespace NotificationChannels\RocketChat; +use DateTime; +use DateTimeZone; use Illuminate\Support\Str; +use InvalidArgumentException; class RocketChatAttachment { @@ -123,13 +126,13 @@ public function text(string $text): self */ public function timestamp($timestamp): self { - if (! ($timestamp instanceof \DateTime) && ! is_string($timestamp)) { - throw new \InvalidArgumentException('Timestamp must be string or DateTime, '.gettype($timestamp).' given.'); + if (! ($timestamp instanceof DateTime) && ! is_string($timestamp)) { + throw new InvalidArgumentException('Timestamp must be string or DateTime, '.gettype($timestamp).' given.'); } - if ($timestamp instanceof \DateTime) { + if ($timestamp instanceof DateTime) { $date = clone $timestamp; - $timestamp = $date->setTimezone(new \DateTimeZone('UTC'))->format('Y-m-d\TH:i:s.v\Z'); + $timestamp = $date->setTimezone(new DateTimeZone('UTC'))->format('Y-m-d\TH:i:s.v\Z'); } $this->timestamp = $timestamp; diff --git a/src/RocketChatMessage.php b/src/RocketChatMessage.php index fc81f72..2556ee4 100644 --- a/src/RocketChatMessage.php +++ b/src/RocketChatMessage.php @@ -6,53 +6,25 @@ class RocketChatMessage { - /** - * RocketChat channel id. - * - * @var string - */ + /** @var string RocketChat channel id. */ public $channel = ''; - /** - * A user or app access token. - * - * @var string - */ + /** @var string A user or app access token. */ public $from = ''; - /** - * The text content of the message. - * - * @var string - */ + /** @var string The text content of the message. */ public $content = ''; - /** - * The alias name of the message. - * - * @var string - */ + /** @var string The alias name of the message. */ public $alias = ''; - /** - * The avatar emoji of the message. - * - * @var string - */ + /** @var string The avatar emoji of the message. */ public $emoji = ''; - /** - * The avatar image of the message. - * - * @var string - */ + /** @var string The avatar image of the message. */ public $avatar = ''; - /** - * Attachments of the message. - * - * @var \NotificationChannels\RocketChat\RocketChatAttachment[] - */ + /** @var \NotificationChannels\RocketChat\RocketChatAttachment[] Attachments of the message. */ public $attachments = []; /** @@ -175,7 +147,7 @@ public function attachment($attachment): self /** * Add multiple attachments to the message. * - * @param array $attachments + * @param array|\NotificationChannels\RocketChat\RocketChatAttachment[] $attachments * @return $this */ public function attachments(array $attachments): self diff --git a/src/RocketChatServiceProvider.php b/src/RocketChatServiceProvider.php index 7bab8f4..5b01111 100644 --- a/src/RocketChatServiceProvider.php +++ b/src/RocketChatServiceProvider.php @@ -17,7 +17,8 @@ final class RocketChatServiceProvider extends ServiceProvider */ public function boot(): void { - $this->app->when(RocketChatWebhookChannel::class) + $this->app + ->when(RocketChatWebhookChannel::class) ->needs(RocketChat::class) ->give(function () { return new RocketChat( diff --git a/src/RocketChatWebhookChannel.php b/src/RocketChatWebhookChannel.php index 56563e4..b11604e 100644 --- a/src/RocketChatWebhookChannel.php +++ b/src/RocketChatWebhookChannel.php @@ -12,11 +12,7 @@ final class RocketChatWebhookChannel { - /** - * The HTTP client instance. - * - * @var \NotificationChannels\RocketChat\RocketChat - */ + /** @var \NotificationChannels\RocketChat\RocketChat The HTTP client instance. */ private $rocketChat; /**