Skip to content

Commit 61e483f

Browse files
sebastiandedeynefreekmurze
authored andcommitted
Nitpicks (#6)
* The ServiceProvider::register method isn't necessary anymore in 5.3 * Helper methods like 'event' require illuminate/foundation * Sorted dependencies * Docblock cleanup * Normalized service provider class name * Cleaned up tests * Prefixed Message and Channel classes with Pusher * Updated authors * illuminate/foundation doesn't exist * Changed pusher dependency to stable releases
1 parent 406832c commit 61e483f

File tree

11 files changed

+45
-49
lines changed

11 files changed

+45
-49
lines changed

README.md

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ You must install the service provider:
3838
// config/app.php
3939
'providers' => [
4040
...
41-
NotificationChannels\PusherPushNotifications\Provider::class,
41+
NotificationChannels\PusherPushNotifications\PusherPushNotificationsServiceProvider::class,
4242
];
4343
```
4444

@@ -60,20 +60,20 @@ Before using this package you should set up a Pusher account. Here are the steps
6060
Now you can use the channel in your `via()` method inside the Notification class.
6161

6262
``` php
63-
use NotificationChannels\PusherPushNotifications\Channel;
64-
use NotificationChannels\PusherPushNotifications\Message;
63+
use NotificationChannels\PusherPushNotifications\PusherChannel;
64+
use NotificationChannels\PusherPushNotifications\PusherMessage;
6565
use Illuminate\Notifications\Notification;
6666

6767
class AccountApproved extends Notification
6868
{
6969
public function via($notifiable)
7070
{
71-
return [Channel::class];
71+
return [PusherChannel::class];
7272
}
7373

7474
public function toPushNotification($notifiable)
7575
{
76-
return Message::create()
76+
return PusherMessage::create()
7777
->iOS()
7878
->badge(1)
7979
->sound('success')
@@ -121,6 +121,7 @@ Please see [CONTRIBUTING](CONTRIBUTING.md) for details.
121121
- [Mohamed Said](https://github.com/themsaid)
122122
- [Marcel Pociot](https://github.com/mpociot)
123123
- [Freek Van der Herten](https://github.com/freekmurze)
124+
- [Sebastian De Deyne](https://github.com/sebastiandedeyne)
124125
- [All Contributors](../../contributors)
125126

126127
## License

composer.json

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,15 +24,20 @@
2424
"name": "Freek Van der Herten",
2525
"email": "[email protected]",
2626
"homepage": "https://spatie.be"
27+
},
28+
{
29+
"name": "Sebastian De Deyne",
30+
"email": "[email protected]",
31+
"homepage": "https://sebastiandedeyne.com"
2732
}
2833
],
2934
"require": {
3035
"php": ">=5.6.4",
31-
"illuminate/notifications": "^5.3@dev",
32-
"illuminate/support": "^5.3@dev",
3336
"illuminate/events": "^5.3@dev",
37+
"illuminate/notifications": "^5.3@dev",
3438
"illuminate/queue": "^5.3@dev",
35-
"pusher/pusher-php-server": "2.5.0-rc4"
39+
"illuminate/support": "^5.3@dev",
40+
"pusher/pusher-php-server": "^2.4.0"
3641
},
3742
"require-dev": {
3843
"mockery/mockery": "^0.9.5",

src/Events/MessageWasSent.php

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -6,20 +6,14 @@
66

77
class MessageWasSent
88
{
9-
/**
10-
* @var
11-
*/
9+
/** @var mixed */
1210
protected $notifiable;
1311

14-
/**
15-
* @var \Illuminate\Notifications\Notification
16-
*/
12+
/** @var \Illuminate\Notifications\Notification */
1713
protected $notification;
1814

1915
/**
20-
* MessageSending constructor.
21-
*
22-
* @param $notifiable
16+
* @param mixed $notifiable
2317
* @param \Illuminate\Notifications\Notification $notification
2418
*/
2519
public function __construct($notifiable, Notification $notification)

src/Events/SendingMessage.php

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -6,18 +6,14 @@
66

77
class SendingMessage
88
{
9-
/**
10-
* @var
11-
*/
9+
/** @var mixed */
1210
protected $notifiable;
1311

14-
/**
15-
* @var \Illuminate\Notifications\Notification
16-
*/
12+
/** @var \Illuminate\Notifications\Notification */
1713
protected $notification;
1814

1915
/**
20-
* @param $notifiable
16+
* @param mixed $notifiable
2117
* @param \Illuminate\Notifications\Notification $notification
2218
*/
2319
public function __construct($notifiable, Notification $notification)

src/Exceptions/CouldNotSendNotification.php

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,11 @@
66

77
class CouldNotSendNotification extends Exception
88
{
9+
/**
10+
* @param array $response
11+
*
12+
* @return static
13+
*/
914
public static function pusherRespondedWithAnError(array $response)
1015
{
1116
return new static("Notification was not sent. Pusher responded with `{$response['code']}: {$response['body']}`");

src/Channel.php renamed to src/PusherChannel.php

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,13 +8,14 @@
88
use Illuminate\Notifications\Notification;
99
use Pusher;
1010

11-
class Channel
11+
class PusherChannel
1212
{
13-
/**
14-
* @var Pusher
15-
*/
13+
/** @var Pusher */
1614
protected $pusher;
1715

16+
/**
17+
* @param \Pusher $pusher
18+
*/
1819
public function __construct(Pusher $pusher)
1920
{
2021
$this->pusher = $pusher;

src/Message.php renamed to src/PusherMessage.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
use Illuminate\Support\Arr;
66
use NotificationChannels\PusherPushNotifications\Exceptions\CouldNotCreateMessage;
77

8-
class Message
8+
class PusherMessage
99
{
1010
/**
1111
* The device platform (iOS/Android).
@@ -50,7 +50,7 @@ class Message
5050
protected $badge;
5151

5252
/**
53-
* Options.
53+
* Extra options that will get added to the message.
5454
*
5555
* @var array
5656
*/

src/Provider.php renamed to src/PusherPushNotificationsServiceProvider.php

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -5,14 +5,14 @@
55
use Illuminate\Support\ServiceProvider;
66
use Pusher;
77

8-
class Provider extends ServiceProvider
8+
class PusherPushNotificationsServiceProvider extends ServiceProvider
99
{
1010
/**
1111
* Bootstrap the application services.
1212
*/
1313
public function boot()
1414
{
15-
$this->app->when(Channel::class)
15+
$this->app->when(PusherChannel::class)
1616
->needs(Pusher::class)
1717
->give(function () {
1818
$pusherConfig = config('broadcasting.connections.pusher');
@@ -24,11 +24,4 @@ public function boot()
2424
);
2525
});
2626
}
27-
28-
/**
29-
* Register the application services.
30-
*/
31-
public function register()
32-
{
33-
}
3427
}

tests/ChannelTest.php

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,8 @@
22

33
namespace NotificationChannels\PusherPushNotifications\Test;
44

5-
use Illuminate\Notifications\Notification;
65
use Mockery;
7-
use NotificationChannels\PusherPushNotifications\Channel;
6+
use NotificationChannels\PusherPushNotifications\PusherChannel;
87
use PHPUnit_Framework_TestCase;
98
use Pusher;
109

@@ -13,15 +12,14 @@ class ChannelTest extends PHPUnit_Framework_TestCase
1312
/** @var Mockery\Mock */
1413
protected $pusher;
1514

16-
/** @var \NotificationChannels\PusherPushNotifications\Channel */
15+
/** @var \NotificationChannels\PusherPushNotifications\PusherChannel */
1716
protected $channel;
1817

19-
/** @test */
2018
public function setUp()
2119
{
2220
$this->pusher = Mockery::mock(Pusher::class);
2321

24-
$this->channel = new Channel($this->pusher);
22+
$this->channel = new PusherChannel($this->pusher);
2523
}
2624

2725
public function tearDown()

tests/MessageTest.php

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,33 +4,33 @@
44

55
use Illuminate\Support\Arr;
66
use NotificationChannels\PusherPushNotifications\Exceptions\CouldNotCreateMessage;
7-
use NotificationChannels\PusherPushNotifications\Message;
7+
use NotificationChannels\PusherPushNotifications\PusherMessage;
88
use PHPUnit_Framework_TestCase;
99

1010
class MessageTest extends PHPUnit_Framework_TestCase
1111
{
12-
/** @var NotificationChannels\PusherPushNotifications\Message */
12+
/** @var \NotificationChannels\PusherPushNotifications\PusherMessage */
1313
protected $message;
1414

1515
public function setUp()
1616
{
1717
parent::setUp();
1818

19-
$this->message = new Message();
19+
$this->message = new PusherMessage();
2020
}
2121

2222
/** @test */
2323
public function it_can_accept_a_message_when_constructing_a_message()
2424
{
25-
$message = new Message('myMessage');
25+
$message = new PusherMessage('myMessage');
2626

2727
$this->assertEquals('myMessage', Arr::get($message->toiOS(), 'apns.aps.alert.body'));
2828
}
2929

3030
/** @test */
3131
public function it_provides_a_create_method()
3232
{
33-
$message = Message::create('myMessage');
33+
$message = PusherMessage::create('myMessage');
3434

3535
$this->assertEquals('myMessage', Arr::get($message->toiOS(), 'apns.aps.alert.body'));
3636
}

0 commit comments

Comments
 (0)