Skip to content

Commit

Permalink
Merge pull request #6 from laravel-notification-channels/hotfix_code-…
Browse files Browse the repository at this point in the history
…style-fix

[Hotfix]: Code style
  • Loading branch information
antonkomarev authored Feb 22, 2020
2 parents c8c1525 + 71d31d9 commit 3baf41e
Show file tree
Hide file tree
Showing 5 changed files with 19 additions and 46 deletions.
1 change: 1 addition & 0 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
"keywords": [
"laravel",
"notifications",
"notification-channel",
"rocketchat",
"rocket.chat",
"chat"
Expand Down
11 changes: 7 additions & 4 deletions src/RocketChatAttachment.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,10 @@

namespace NotificationChannels\RocketChat;

use DateTime;
use DateTimeZone;
use Illuminate\Support\Str;
use InvalidArgumentException;

class RocketChatAttachment
{
Expand Down Expand Up @@ -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;

Expand Down
44 changes: 8 additions & 36 deletions src/RocketChatMessage.php
Original file line number Diff line number Diff line change
Expand Up @@ -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 = [];

/**
Expand Down Expand Up @@ -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
Expand Down
3 changes: 2 additions & 1 deletion src/RocketChatServiceProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down
6 changes: 1 addition & 5 deletions src/RocketChatWebhookChannel.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;

/**
Expand Down

0 comments on commit 3baf41e

Please sign in to comment.