Skip to content

Commit 1485a06

Browse files
committed
Revert the TwitterNotification implementation
1 parent 4da540d commit 1485a06

File tree

5 files changed

+18
-43
lines changed

5 files changed

+18
-43
lines changed

CHANGELOG.md

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,6 @@ All notable changes to the `Twitter notification channel` will be documented in
66
### Added
77
- Abstract parent class `TwitterMessage` for
88
`TwitterStatusUpdate` and `TwitterDirectMessage`.
9-
- Abstract parent class `TwitterNotification` having
10-
the default implementation of `via` and defining
11-
the `toTwitter` method that needs to return an
12-
instance of the new `TwitterMessage` class.
139

1410
### Changed
1511
- Add a lot of missing argument and return types.

README.md

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -72,13 +72,24 @@ To use this package, you need to create a notification class, like `NewsWasPubli
7272
```php
7373
<?php
7474

75+
use Illuminate\Notifications\Notification;
7576
use NotificationChannels\Twitter\TwitterChannel;
7677
use NotificationChannels\Twitter\TwitterMessage;
77-
use NotificationChannels\Twitter\TwitterNotification;
7878
use NotificationChannels\Twitter\TwitterStatusUpdate;
7979

80-
class NewsWasPublished extends TwitterNotification
80+
class NewsWasPublished extends Notification
8181
{
82+
/**
83+
* Get the notification's delivery channels.
84+
*
85+
* @param mixed $notifiable
86+
* @return array
87+
*/
88+
public function via($notifiable)
89+
{
90+
return [TwitterChannel::class];
91+
}
92+
8293
public function toTwitter(mixed $notifiable): TwitterMessage
8394
{
8495
return new TwitterStatusUpdate('Laravel notifications are awesome!');
@@ -88,8 +99,6 @@ class NewsWasPublished extends TwitterNotification
8899

89100
Take a closer look at the `toTwitter` method. Here we define what kind of Twitter message we want to trigger. In this case, it is a status update message, which is just a new message in your timeline.
90101

91-
It's recommended to also implement the `TwitterNotification` interface that requires the `toTwitter` method and also that it returns an instance of `TwitterMessage`.
92-
93102
````php
94103
public function toTwitter(mixed $notifiable): TwitterMessage
95104
{

src/TwitterChannel.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
namespace NotificationChannels\Twitter;
44

55
use Abraham\TwitterOAuth\TwitterOAuth;
6+
use Illuminate\Notifications\Notification;
67
use NotificationChannels\Twitter\Exceptions\CouldNotSendNotification;
78

89
class TwitterChannel
@@ -18,7 +19,7 @@ public function __construct(protected TwitterOAuth $twitter)
1819
*
1920
* @throws CouldNotSendNotification
2021
*/
21-
public function send($notifiable, TwitterNotification $notification): array|object
22+
public function send($notifiable, Notification $notification): array|object
2223
{
2324
$this->changeTwitterSettingsIfNeeded($notifiable);
2425

src/TwitterNotification.php

Lines changed: 0 additions & 25 deletions
This file was deleted.

tests/TwitterChannelTest.php

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,11 @@
33
namespace NotificationChannels\Twitter\Test;
44

55
use Abraham\TwitterOAuth\TwitterOAuth;
6+
use Illuminate\Notifications\Notification;
67
use Mockery;
78
use NotificationChannels\Twitter\Exceptions\CouldNotSendNotification;
89
use NotificationChannels\Twitter\TwitterChannel;
910
use NotificationChannels\Twitter\TwitterMessage;
10-
use NotificationChannels\Twitter\TwitterNotification;
1111
use NotificationChannels\Twitter\TwitterStatusUpdate;
1212
use stdClass;
1313

@@ -122,12 +122,9 @@ public function routeNotificationForTwitter()
122122
}
123123
}
124124

125-
class TestNotification extends TwitterNotification
125+
class TestNotification extends Notification
126126
{
127127
/**
128-
* @param mixed $notifiable
129-
* @return TwitterStatusUpdate
130-
*
131128
* @throws CouldNotSendNotification
132129
*/
133130
public function toTwitter(mixed $notifiable): TwitterMessage
@@ -136,12 +133,9 @@ public function toTwitter(mixed $notifiable): TwitterMessage
136133
}
137134
}
138135

139-
class TestNotificationWithImage extends TwitterNotification
136+
class TestNotificationWithImage extends Notification
140137
{
141138
/**
142-
* @param mixed $notifiable
143-
* @return TwitterStatusUpdate
144-
*
145139
* @throws CouldNotSendNotification
146140
*/
147141
public function toTwitter(mixed $notifiable): TwitterMessage

0 commit comments

Comments
 (0)