Skip to content

fix: laravel 9, make default name static #70

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

Merged
merged 1 commit into from
Feb 7, 2022
Merged
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
12 changes: 6 additions & 6 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -32,16 +32,16 @@
}
],
"require": {
"php": ">=7.0",
"illuminate/events": "~5.5 || ~6.0 || ~7.0 || ~8.0",
"illuminate/notifications": "~5.5 || ~6.0 || ~7.0 || ~8.0",
"illuminate/queue": "~5.5 || ~6.0 || ~7.0 || ~8.0",
"illuminate/support": "~5.5 || ~6.0 || ~7.0 || ~8.0",
"php": ">=7.4",
"illuminate/events": "~7.0 || ~8.0 || ~9.0",
"illuminate/notifications": "~7.0 || ~8.0 || ~9.0",
"illuminate/queue": "~7.0 || ~8.0 || ~9.0",
"illuminate/support": "~7.0 || ~8.0 || ~9.0",
"pusher/pusher-push-notifications": "^1.1"
},
"require-dev": {
"mockery/mockery": "^1.3",
"phpunit/phpunit": "^8.5"
"phpunit/phpunit": "^9.5"
},
"autoload": {
"psr-4": {
Expand Down
35 changes: 11 additions & 24 deletions src/PusherChannel.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
<?php

declare(strict_types=1);

namespace NotificationChannels\PusherPushNotifications;

use Illuminate\Contracts\Events\Dispatcher;
Expand All @@ -12,25 +14,12 @@

class PusherChannel
{
/**
* @var string
*/
const INTERESTS = 'interests';
public const INTERESTS = 'interests';

/**
* @var PushNotifications
*/
protected $beamsClient;
protected PushNotifications $beamsClient;

/**
* @var \Illuminate\Contracts\Events\Dispatcher
*/
private $events;
private Dispatcher $events;

/**
* @param PushNotifications $beamsClient
* @param Dispatcher $events
*/
public function __construct(PushNotifications $beamsClient, Dispatcher $events)
{
$this->beamsClient = $beamsClient;
Expand All @@ -40,17 +29,16 @@ public function __construct(PushNotifications $beamsClient, Dispatcher $events)
/**
* Send the given notification.
*
* @param mixed $notifiable
* @param \Illuminate\Notifications\Notification $notification
*
* @param mixed $notifiable
* @param Notification $notification
* @return void
*/
public function send($notifiable, Notification $notification)
public function send($notifiable, Notification $notification): void
{
$type = $notifiable->pushNotificationType ?? self::INTERESTS;

$data = $notifiable->routeNotificationFor('PusherPushNotifications')
?: $this->defaultName($notifiable);
?: self::defaultName($notifiable);

try {
$notificationType = sprintf('publishTo%s', Str::ucfirst($type));
Expand All @@ -69,11 +57,10 @@ public function send($notifiable, Notification $notification)
/**
* Get the default name for the notifiable.
*
* @param $notifiable
*
* @param mixed $notifiable
* @return string
*/
protected function defaultName($notifiable)
public static function defaultName($notifiable): string
{
$class = str_replace('\\', '.', get_class($notifiable));

Expand Down