Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Switched to PHP 7.4, used typed properties where possible #61

Draft
wants to merge 6 commits into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 5 additions & 2 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,10 @@ jobs:
strategy:
fail-fast: true
matrix:
php: [7.3, 7.4, 8.0, 8.1]
php:
- 7.4
- 8.0
- 8.1
dependencies:
- lowest
- highest
Expand All @@ -29,7 +32,7 @@ jobs:
coverage: none

- name: Composer install
uses: "ramsey/composer-install@v1"
uses: ramsey/composer-install@v1
with:
dependency-versions: "${{ matrix.dependencies }}"

Expand Down
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@

All notable changes to `laravel-notification-channels/pushbullet` will be documented in this file

## 1.4.0 - Unreleased
### Changed
- Bumped PHP requirement to 7.4

## 1.3.1 - 2021-12-17
### Changed
- Minor CI improvements
Expand Down
5 changes: 2 additions & 3 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,13 @@
}
],
"require": {
"php": "^7.3 || ~8.0.0 || ~8.1.0",
"php": "^7.4 || ~8.0.0 || ~8.1.0",
"guzzlehttp/guzzle": "^6.2 || ^7.0",
"illuminate/notifications": "~5.5 || ~6.0 || ~7.0 || ~8.0",
"illuminate/support": "~5.5 || ~6.0 || ~7.0 || ~8.0"
},
"require-dev": {
"mockery/mockery": "^1.2.0",
"phpunit/phpunit": "^8.5.21 || ^9.0"
"phpunit/phpunit": "^9.0"
},
"autoload": {
"psr-4": {
Expand Down
45 changes: 16 additions & 29 deletions phpunit.xml.dist
Original file line number Diff line number Diff line change
@@ -1,31 +1,18 @@
<?xml version="1.0" encoding="UTF-8"?>
<phpunit bootstrap="vendor/autoload.php"
backupGlobals="false"
backupStaticAttributes="false"
colors="true"
verbose="true"
convertErrorsToExceptions="true"
convertNoticesToExceptions="true"
convertWarningsToExceptions="true"
processIsolation="false"
stopOnFailure="false">
<testsuites>
<testsuite name="Pushbullet Notification Channel Test Suite">
<directory suffix="Test.php">tests</directory>
</testsuite>
</testsuites>

<filter>
<whitelist processUncoveredFilesFromWhitelist="true">
<directory suffix=".php">src</directory>
</whitelist>
</filter>

<logging>
<log type="tap" target="build/report.tap"/>
<log type="junit" target="build/report.junit.xml"/>
<log type="coverage-html" target="build/coverage"/>
<log type="coverage-text" target="build/coverage.txt"/>
<log type="coverage-clover" target="build/logs/clover.xml"/>
</logging>
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" bootstrap="vendor/autoload.php" backupGlobals="false" backupStaticAttributes="false" colors="true" verbose="true" convertErrorsToExceptions="true" convertNoticesToExceptions="true" convertWarningsToExceptions="true" processIsolation="false" stopOnFailure="false" xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/9.3/phpunit.xsd">
<coverage>
<report>
<clover outputFile="build/logs/clover.xml"/>
<html outputDirectory="build/coverage"/>
<text outputFile="build/coverage.txt"/>
</report>
</coverage>
<testsuites>
<testsuite name="Pushbullet Notification Channel Test Suite">
<directory suffix="Test.php">tests</directory>
</testsuite>
</testsuites>
<logging>
<junit outputFile="build/report.junit.xml"/>
</logging>
</phpunit>
17 changes: 3 additions & 14 deletions src/Pushbullet.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,18 +12,10 @@

class Pushbullet
{
/** @var string */
private $token;
private string $token;

/** @var \GuzzleHttp\Client */
private $httpClient;
private HttpClient $httpClient;

/**
* Create small Pushbullet client.
*
* @param string $token
* @param \GuzzleHttp\Client $httpClient
*/
public function __construct(string $token, HttpClient $httpClient)
{
$this->token = $token;
Expand All @@ -32,8 +24,6 @@ public function __construct(string $token, HttpClient $httpClient)

/**
* Get url to send to Pushbullet API?
*
* @return string
*/
private function getPushbulletUrl(): string
{
Expand All @@ -43,7 +33,7 @@ private function getPushbulletUrl(): string
/**
* Get headers for API calls.
*
* @return array
* @return array<string, string>
*/
private function getHeaders(): array
{
Expand All @@ -56,7 +46,6 @@ private function getHeaders(): array
* Send request to Pushbullet API.
*
* @param array $params
* @return \Psr\Http\Message\ResponseInterface
*/
public function send($params): ResponseInterface
{
Expand Down
10 changes: 2 additions & 8 deletions src/PushbulletChannel.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,8 @@

class PushbulletChannel
{
/** @var \NotificationChannels\Pushbullet\Pushbullet */
private $pushbullet;
private Pushbullet $pushbullet;

/**
* @param \NotificationChannels\Pushbullet\Pushbullet $pushbullet
*/
public function __construct(Pushbullet $pushbullet)
{
$this->pushbullet = $pushbullet;
Expand All @@ -26,7 +22,6 @@ public function __construct(Pushbullet $pushbullet)
* Send the given notification.
*
* @param mixed $notifiable
* @param \Illuminate\Notifications\Notification $notification
*
* @throws \NotificationChannels\Pushbullet\Exceptions\CouldNotSendNotification
*/
Expand All @@ -43,8 +38,7 @@ public function send($notifiable, Notification $notification): void
}

/**
* @param $notifiable
* @return \NotificationChannels\Pushbullet\Targets\Targetable|void
* @param Targetable|string $notifiable
*/
private function getTarget($notifiable): ?Targetable
{
Expand Down
7 changes: 1 addition & 6 deletions src/PushbulletMessage.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,7 @@ class PushbulletMessage
*/
public $type = 'note';

/** @var \NotificationChannels\Pushbullet\Targets\Targetable */
protected $target;
protected Targetable $target;

/**
* Notification title.
Expand Down Expand Up @@ -60,7 +59,6 @@ public function __construct($message)
}

/**
* @param \NotificationChannels\Pushbullet\Targets\Targetable $targetable
* @return $this
*/
public function target(Targetable $targetable): self
Expand Down Expand Up @@ -153,9 +151,6 @@ public function toArray(): array
);
}

/**
* @return bool
*/
private function isLink(): bool
{
return $this->type === self::TYPE_LINK;
Expand Down
11 changes: 2 additions & 9 deletions src/Targets/Channel.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,21 +6,14 @@

class Channel implements Targetable
{
/**
* PushBullet channel tag.
*
* @var string
*/
private $channelTag;
private string $channelTag;

/**
* Set channel tag.
*
* @param string $channelTag
*/
public function __construct($channelTag)
{
$this->channelTag = $channelTag;
$this->channelTag = (string) $channelTag;
}

/**
Expand Down
11 changes: 2 additions & 9 deletions src/Targets/Device.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,21 +6,14 @@

class Device implements Targetable
{
/**
* Recipient device id.
*
* @var string
*/
private $deviceId;
private string $deviceId;

/**
* Set recipient device id.
*
* @param string $device
*/
public function __construct($device)
{
$this->deviceId = $device;
$this->deviceId = (string) $device;
}

/**
Expand Down
9 changes: 2 additions & 7 deletions src/Targets/Email.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,7 @@

class Email implements Targetable
{
/**
* Recipient email.
*
* @var string
*/
private $email;
private string $email;

/**
* Set recipient email.
Expand All @@ -26,7 +21,7 @@ public function __construct($email)
throw CouldNotSendNotification::providedEmailIsInvalid($email);
}

$this->email = $email;
$this->email = (string) $email;
}

/**
Expand Down