Skip to content

Commit

Permalink
Apply code formatting changes suggested by Style CI
Browse files Browse the repository at this point in the history
  • Loading branch information
Kovah committed Mar 20, 2024
1 parent 39c6372 commit 26ab126
Show file tree
Hide file tree
Showing 5 changed files with 45 additions and 36 deletions.
17 changes: 9 additions & 8 deletions src/Pushover.php
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,8 @@ class Pushover
protected string $token;

/**
* @param HttpClient $http
* @param string $token
* @param HttpClient $http
* @param string $token
*/
public function __construct(HttpClient $http, string $token)
{
Expand All @@ -56,8 +56,8 @@ public function __construct(HttpClient $http, string $token)
*
* @link https://pushover.net/api
*
* @param array $params
* @param mixed $notifiable
* @param array $params
* @param mixed $notifiable
* @return ResponseInterface
*
* @throws CouldNotSendNotification
Expand Down Expand Up @@ -106,7 +106,7 @@ public function send(array $params, mixed $notifiable): ResponseInterface
/**
* Merge token into parameters array, unless it has been set on the PushoverReceiver.
*
* @param array $params
* @param array $params
* @return array
*/
protected function paramsWithToken(array $params): array
Expand All @@ -122,8 +122,9 @@ protected function paramsWithToken(array $params): array
* If there is any error (problem with reading the file, file size exceeds the limit, the file is not an image),
* silently returns null and sends the message without image attachment.
*
* @param $file
* @param $file
* @return array|null
*
* @throws GuzzleException
*/
private function getImageData($file): ?array
Expand Down Expand Up @@ -151,7 +152,7 @@ private function getImageData($file): ?array
}

// some servers may not return the "Content-Length" header
$fileSizeChecked = (bool)$contentLength;
$fileSizeChecked = (bool) $contentLength;
}

// check if $file is an image
Expand All @@ -163,7 +164,7 @@ private function getImageData($file): ?array

$contents = file_get_contents($file);
// if not checked before, finally check the file size after reading it
if (!$fileSizeChecked && strlen($contents) > self::IMAGE_SIZE_LIMIT) {
if (! $fileSizeChecked && strlen($contents) > self::IMAGE_SIZE_LIMIT) {
return null;
}
} catch (Exception $exception) {
Expand Down
8 changes: 4 additions & 4 deletions src/PushoverChannel.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@ class PushoverChannel
/**
* Create a new Pushover channel instance.
*
* @param Pushover $pushover
* @param Dispatcher $events
* @param Pushover $pushover
* @param Dispatcher $events
*/
public function __construct(Pushover $pushover, Dispatcher $events)
{
Expand All @@ -30,8 +30,8 @@ public function __construct(Pushover $pushover, Dispatcher $events)
/**
* Send the given notification.
*
* @param mixed $notifiable
* @param Notification $notification
* @param mixed $notifiable
* @param Notification $notification
*
* @throws CouldNotSendNotification
* @throws GuzzleException
Expand Down
42 changes: 24 additions & 18 deletions src/PushoverMessage.php
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ class PushoverMessage
public const EMERGENCY_PRIORITY = 2;

/**
* @param string $content
* @param string $content
* @return static
*/
public static function create(string $content = ''): static
Expand All @@ -112,7 +112,7 @@ public static function create(string $content = ''): static
}

/**
* @param string $content
* @param string $content
*/
public function __construct(string $content = '')
{
Expand All @@ -122,7 +122,7 @@ public function __construct(string $content = '')
/**
* Set the content of the Pushover message.
*
* @param string $content
* @param string $content
* @return $this
*/
public function content(string $content): static
Expand Down Expand Up @@ -171,7 +171,7 @@ public function monospace(): static
/**
* Set the title of the Pushover message.
*
* @param string $title
* @param string $title
* @return $this
*/
public function title(string $title): static
Expand All @@ -184,13 +184,13 @@ public function title(string $title): static
/**
* Set the time of the Pushover message.
*
* @param int|Carbon $time
* @param int|Carbon $time
* @return $this
*/
public function time(int|Carbon $time): static
{
if ($time instanceof Carbon) {
$time = (int)$time->timestamp;
$time = (int) $time->timestamp;
}

$this->timestamp = $time;
Expand All @@ -201,8 +201,8 @@ public function time(int|Carbon $time): static
/**
* Set a supplementary url for the Pushover message.
*
* @param string $url
* @param string $title
* @param string $url
* @param string $title
* @return $this
*/
public function url(string $url, string $title = ''): static
Expand All @@ -216,7 +216,7 @@ public function url(string $url, string $title = ''): static
/**
* Set the sound of the Pushover message.
*
* @param string $sound
* @param string $sound
* @return $this
*/
public function sound(string $sound): static
Expand All @@ -229,7 +229,7 @@ public function sound(string $sound): static
/**
* Set the image for attaching to the Pushover message. Either full or relative server path or a URL.
*
* @param string $image
* @param string $image
* @return $this
*/
public function image(string $image): static
Expand All @@ -243,10 +243,11 @@ public function image(string $image): static
* Set the priority of the Pushover message.
* Retry and expire are mandatory when setting the priority to emergency.
*
* @param int $priority
* @param int|null $retryTimeout
* @param int|null $expireAfter
* @param int $priority
* @param int|null $retryTimeout
* @param int|null $expireAfter
* @return $this
*
* @throws EmergencyNotificationRequiresRetryAndExpire
*/
public function priority(int $priority, int|null $retryTimeout = null, int|null $expireAfter = null): static
Expand All @@ -264,6 +265,7 @@ public function priority(int $priority, int|null $retryTimeout = null, int|null
* Set the priority of the Pushover message to the lowest priority.
*
* @return $this
*
* @throws EmergencyNotificationRequiresRetryAndExpire
*/
public function lowestPriority(): static
Expand All @@ -275,6 +277,7 @@ public function lowestPriority(): static
* Set the priority of the Pushover message to low.
*
* @return $this
*
* @throws EmergencyNotificationRequiresRetryAndExpire
*/
public function lowPriority(): static
Expand All @@ -286,6 +289,7 @@ public function lowPriority(): static
* Set the priority of the Pushover message to normal.
*
* @return $this
*
* @throws EmergencyNotificationRequiresRetryAndExpire
*/
public function normalPriority(): static
Expand All @@ -297,6 +301,7 @@ public function normalPriority(): static
* Set the priority of the Pushover message to high.
*
* @return $this
*
* @throws EmergencyNotificationRequiresRetryAndExpire
*/
public function highPriority(): static
Expand All @@ -308,9 +313,10 @@ public function highPriority(): static
* Set the priority of the Pushover message to emergency.
* Retry and expire are mandatory when setting the priority to emergency.
*
* @param int $retryTimeout
* @param int $expireAfter
* @param int $retryTimeout
* @param int $expireAfter
* @return $this
*
* @throws EmergencyNotificationRequiresRetryAndExpire
*/
public function emergencyPriority(int $retryTimeout, int $expireAfter): static
Expand Down Expand Up @@ -344,9 +350,9 @@ public function toArray(): array
/**
* Ensure an emergency message has an retry and expiry time.
*
* @param int $priority
* @param int|null $retry
* @param int|null $expire
* @param int $priority
* @param int|null $retry
* @param int|null $expire
*
* @throws EmergencyNotificationRequiresRetryAndExpire
*/
Expand Down
12 changes: 7 additions & 5 deletions src/PushoverReceiver.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ class PushoverReceiver
/**
* PushoverReceiver constructor.
*
* @param string $key User or group key.
* @param string $key User or group key.
*/
protected function __construct(string $key)
{
Expand All @@ -21,7 +21,7 @@ protected function __construct(string $key)
/**
* Create new Pushover receiver with an user key.
*
* @param string $userKey Pushover user key.
* @param string $userKey Pushover user key.
* @return PushoverReceiver
*/
public static function withUserKey(string $userKey): PushoverReceiver
Expand All @@ -32,7 +32,7 @@ public static function withUserKey(string $userKey): PushoverReceiver
/**
* Create new Pushover receiver with a group key.
*
* @param string $groupKey Pushover group key.
* @param string $groupKey Pushover group key.
* @return PushoverReceiver
*/
public static function withGroupKey(string $groupKey): PushoverReceiver
Expand All @@ -45,24 +45,26 @@ public static function withGroupKey(string $groupKey): PushoverReceiver
/**
* Send the message to a specific device.
*
* @param array|string $device
* @param array|string $device
* @return PushoverReceiver
*/
public function toDevice(array|string $device): static
{
if (is_array($device)) {
$this->devices = array_merge($device, $this->devices);

return $this;
}

$this->devices[] = $device;

return $this;
}

/**
* Set the application token.
*
* @param $token
* @param $token
* @return PushoverReceiver
*/
public function withApplicationToken($token): static
Expand Down
2 changes: 1 addition & 1 deletion tests/IntegrationTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ public function it_can_send_a_pushover_notification_with_an_overridden_token():
protected function requestWillBeSentToPushoverWith($params): void
{
$multipartData = array_map(
fn($key, $value) => ['name' => $key, 'contents' => $value],
fn ($key, $value) => ['name' => $key, 'contents' => $value],
array_keys($params),
array_values($params)
);
Expand Down

0 comments on commit 26ab126

Please sign in to comment.