-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #43 from laravel-notification-channels/improvements
Code improvements
- Loading branch information
Showing
13 changed files
with
134 additions
and
58 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,3 +3,4 @@ build | |
composer.phar | ||
composer.lock | ||
.phpunit.result.cache | ||
build/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,33 +1,30 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace NotificationChannels\Pushbullet\Exceptions; | ||
|
||
use GuzzleHttp\Exception\ClientException; | ||
use Psr\Http\Message\ResponseInterface; | ||
use RuntimeException; | ||
|
||
class CouldNotSendNotification extends RuntimeException | ||
{ | ||
public static function pushbulletRespondedWithAnError(ClientException $exception) | ||
public static function pushbulletRespondedWithAnError(ResponseInterface $response): self | ||
{ | ||
$code = $exception->getResponse()->getStatusCode(); | ||
|
||
$message = $exception->getResponse()->getBody(); | ||
$code = $response->getStatusCode(); | ||
|
||
return new static("Pushbullet responded with an error `{$code} - {$message}`"); | ||
} | ||
$message = $response->getBody(); | ||
|
||
public static function providedEmailIsInvalid($email) | ||
{ | ||
return new static("Provided email `{$email}` of `notifiable` is not valid"); | ||
return new self("Pushbullet responded with error: `{$code} - {$message}`."); | ||
} | ||
|
||
public static function couldNotSendNotificationWithoutRecipient() | ||
public static function providedEmailIsInvalid(string $email): self | ||
{ | ||
return new static('Neither device id nor email of recipient was not specified'); | ||
return new self("Provided email `{$email}` of `notifiable` is not valid."); | ||
} | ||
|
||
public static function couldNotCommunicateWithPushbullet() | ||
public static function couldNotCommunicateWithPushbullet(): self | ||
{ | ||
return new static("Couldn't connect to Pushbullet API."); | ||
return new self('Could not connect to Pushbullet API.'); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,24 +1,22 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace NotificationChannels\Pushbullet; | ||
|
||
use GuzzleHttp\Client as HttpClient; | ||
use Illuminate\Support\ServiceProvider; | ||
|
||
class PushbulletServiceProvider extends ServiceProvider | ||
{ | ||
/** | ||
* Bootstrap the application services. | ||
*/ | ||
public function boot() | ||
public function boot(): void | ||
{ | ||
// Bootstrap code here. | ||
$this->app->when(PushbulletChannel::class) | ||
->needs(Pushbullet::class) | ||
->give(function () { | ||
->give(static function (): Pushbullet { | ||
$config = config('services.pushbullet'); | ||
|
||
return new Pushbullet($config['access_token'], new HttpClient); | ||
return new Pushbullet($config['access_token'], new HttpClient()); | ||
}); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,7 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace NotificationChannels\Pushbullet\Targets; | ||
|
||
interface Targetable | ||
|
Oops, something went wrong.