diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index e845aca..f7405f7 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -10,7 +10,7 @@ on: jobs: tests: - runs-on: ubuntu-23.10 + runs-on: ubuntu-22.04 strategy: fail-fast: true diff --git a/.styleci.yml b/.styleci.yml deleted file mode 100644 index e04bb81..0000000 --- a/.styleci.yml +++ /dev/null @@ -1,4 +0,0 @@ -php: - preset: laravel -js: true -css: true \ No newline at end of file diff --git a/config/sms-factor.php b/config/sms-factor.php index 2bc14b9..2aa4609 100644 --- a/config/sms-factor.php +++ b/config/sms-factor.php @@ -25,4 +25,4 @@ */ 'api_token' => env('SMS_FACTOR_TOKEN'), -]; \ No newline at end of file +]; diff --git a/src/Channels/SmsFactorSmsChannel.php b/src/Channels/SmsFactorSmsChannel.php index f8496f8..97e421c 100644 --- a/src/Channels/SmsFactorSmsChannel.php +++ b/src/Channels/SmsFactorSmsChannel.php @@ -2,22 +2,23 @@ namespace Xefi\SmsFactor\Channels; -use Xefi\SmsFactor\Messages\SmsFactorMessage; -use SMSFactor\Message; use Illuminate\Notifications\Notification; +use SMSFactor\Message; +use Xefi\SmsFactor\Messages\SmsFactorMessage; class SmsFactorSmsChannel extends Notification { /** * Send the given notification. * - * @param mixed $notifiable - * @param \Illuminate\Notifications\Notification $notification + * @param mixed $notifiable + * @param \Illuminate\Notifications\Notification $notification + * * @return \SmsFactor\ApiResponse */ public function send($notifiable, Notification $notification) { - if (! $to = $notifiable->routeNotificationFor('sms-factor', $notification)) { + if (!$to = $notifiable->routeNotificationFor('sms-factor', $notification)) { return; } @@ -28,12 +29,12 @@ public function send($notifiable, Notification $notification) } return Message::send([ - 'to' => $to, - 'text' => trim($message->text), - 'delay' => $message->delay, + 'to' => $to, + 'text' => trim($message->text), + 'delay' => $message->delay, 'pushtype' => $message->pushtype ?? null, - 'sender' => $message->sender ?? config('sms-factor.sms_from'), + 'sender' => $message->sender ?? config('sms-factor.sms_from'), 'gsmsmsid' => $message->gsmsmsid ?? null, ]); } -} \ No newline at end of file +} diff --git a/src/Messages/SmsFactorMessage.php b/src/Messages/SmsFactorMessage.php index 77242fb..ee90ba8 100644 --- a/src/Messages/SmsFactorMessage.php +++ b/src/Messages/SmsFactorMessage.php @@ -44,7 +44,8 @@ class SmsFactorMessage /** * Set the message text. * - * @param string $text + * @param string $text + * * @return $this */ public function text($text) @@ -57,7 +58,8 @@ public function text($text) /** * Set the message pushtype. * - * @param string $pushtype + * @param string $pushtype + * * @return $this */ public function pushtype($pushtype) @@ -70,7 +72,8 @@ public function pushtype($pushtype) /** * Set the message delay. * - * @param \Carbon\Carbon $delay + * @param \Carbon\Carbon $delay + * * @return $this */ public function delay($delay) @@ -87,7 +90,8 @@ public function delay($delay) /** * Set the message sender. * - * @param string $sender + * @param string $sender + * * @return $this */ public function sender($sender) @@ -100,7 +104,8 @@ public function sender($sender) /** * Set the message gsmsmsid. * - * @param string $gsmsmsid + * @param string $gsmsmsid + * * @return $this */ public function gsmsmsid($gsmsmsid) @@ -109,4 +114,4 @@ public function gsmsmsid($gsmsmsid) return $this; } -} \ No newline at end of file +} diff --git a/src/SmsFactorChannelServiceProvider.php b/src/SmsFactorChannelServiceProvider.php index 3573115..d8256b0 100644 --- a/src/SmsFactorChannelServiceProvider.php +++ b/src/SmsFactorChannelServiceProvider.php @@ -2,10 +2,10 @@ namespace Xefi\SmsFactor; +use Illuminate\Notifications\ChannelManager; +use Illuminate\Support\Facades\Notification; use Illuminate\Support\ServiceProvider; use Xefi\SmsFactor\Channels\SmsFactorSmsChannel; -use Illuminate\Support\Facades\Notification; -use Illuminate\Notifications\ChannelManager; class SmsFactorChannelServiceProvider extends ServiceProvider { @@ -16,7 +16,7 @@ class SmsFactorChannelServiceProvider extends ServiceProvider */ public function register() { - $this->mergeConfigFrom(__DIR__ . '/../config/sms-factor.php', 'sms-factor'); + $this->mergeConfigFrom(__DIR__.'/../config/sms-factor.php', 'sms-factor'); Notification::resolved(function (ChannelManager $service) { $service->extend('sms-factor', function ($app) { @@ -40,4 +40,4 @@ public function boot() ], 'sms-factor'); } } -} \ No newline at end of file +} diff --git a/tests/Unit/Channels/SmsFactorSmsChannelTest.php b/tests/Unit/Channels/SmsFactorSmsChannelTest.php index 92efb53..3ca048e 100644 --- a/tests/Unit/Channels/SmsFactorSmsChannelTest.php +++ b/tests/Unit/Channels/SmsFactorSmsChannelTest.php @@ -11,7 +11,6 @@ use SMSFactor\SMSFactor; use Xefi\SmsFactor\Channels\SmsFactorSmsChannel; use Xefi\SmsFactor\Messages\SmsFactorMessage; -use Xefi\SmsFactor\SmsFactorChannelServiceProvider; class SmsFactorSmsChannelTest extends TestCase { @@ -24,8 +23,8 @@ protected function setUp(): void public function testSmsIsSentViaSmsFactor() { - $notification = new NotificationSmsFactorSmsChannelTestNotification; - $notifiable = new NotificationSmsFactorSmsChannelTestNotifiable; + $notification = new NotificationSmsFactorSmsChannelTestNotification(); + $notifiable = new NotificationSmsFactorSmsChannelTestNotifiable(); $channel = new SmsFactorSmsChannel(); @@ -33,11 +32,11 @@ public function testSmsIsSentViaSmsFactor() $mock->shouldReceive('send') ->with( [ - 'to' => '5555555555', - 'text' => 'this is my message', - 'delay' => null, + 'to' => '5555555555', + 'text' => 'this is my message', + 'delay' => null, 'pushtype' => null, - 'sender' => null, + 'sender' => null, 'gsmsmsid' => null, ] ) @@ -49,8 +48,8 @@ public function testSmsIsSentViaSmsFactor() public function testSmsIsSentViaSmsFactorWithCustomSender() { - $notification = new NotificationSmsFactorSmsChannelTestCustomSenderNotification; - $notifiable = new NotificationSmsFactorSmsChannelTestNotifiable; + $notification = new NotificationSmsFactorSmsChannelTestCustomSenderNotification(); + $notifiable = new NotificationSmsFactorSmsChannelTestNotifiable(); $channel = new SmsFactorSmsChannel(); @@ -58,11 +57,11 @@ public function testSmsIsSentViaSmsFactorWithCustomSender() $mock->shouldReceive('send') ->with( [ - 'to' => '5555555555', - 'text' => 'this is my message', - 'delay' => null, + 'to' => '5555555555', + 'text' => 'this is my message', + 'delay' => null, 'pushtype' => null, - 'sender' => '12345', + 'sender' => '12345', 'gsmsmsid' => null, ] ) @@ -74,8 +73,8 @@ public function testSmsIsSentViaSmsFactorWithCustomSender() public function testSmsIsSentViaSmsFactorWithCustomDelay() { - $notification = new NotificationSmsFactorSmsChannelTestCustomDelayNotification; - $notifiable = new NotificationSmsFactorSmsChannelTestNotifiable; + $notification = new NotificationSmsFactorSmsChannelTestCustomDelayNotification(); + $notifiable = new NotificationSmsFactorSmsChannelTestNotifiable(); $channel = new SmsFactorSmsChannel(); @@ -83,11 +82,11 @@ public function testSmsIsSentViaSmsFactorWithCustomDelay() $mock->shouldReceive('send') ->with( [ - 'to' => '5555555555', - 'text' => 'this is my message', - 'delay' => Carbon::create(2024, 01, 01)->format('Y-m-d H:i:s'), + 'to' => '5555555555', + 'text' => 'this is my message', + 'delay' => Carbon::create(2024, 01, 01)->format('Y-m-d H:i:s'), 'pushtype' => null, - 'sender' => null, + 'sender' => null, 'gsmsmsid' => null, ] ) @@ -99,8 +98,8 @@ public function testSmsIsSentViaSmsFactorWithCustomDelay() public function testSmsIsSentViaSmsFactorWithCustomPushType() { - $notification = new NotificationSmsFactorSmsChannelTestCustomPushTypeNotification; - $notifiable = new NotificationSmsFactorSmsChannelTestNotifiable; + $notification = new NotificationSmsFactorSmsChannelTestCustomPushTypeNotification(); + $notifiable = new NotificationSmsFactorSmsChannelTestNotifiable(); $channel = new SmsFactorSmsChannel(); @@ -108,11 +107,11 @@ public function testSmsIsSentViaSmsFactorWithCustomPushType() $mock->shouldReceive('send') ->with( [ - 'to' => '5555555555', - 'text' => 'this is my message', - 'delay' => null, + 'to' => '5555555555', + 'text' => 'this is my message', + 'delay' => null, 'pushtype' => 'alert', - 'sender' => null, + 'sender' => null, 'gsmsmsid' => null, ] ) @@ -124,8 +123,8 @@ public function testSmsIsSentViaSmsFactorWithCustomPushType() public function testSmsIsSentViaSmsFactorWithCustomGsmsmsid() { - $notification = new NotificationSmsFactorSmsChannelTestCustomGsmsmsidNotification; - $notifiable = new NotificationSmsFactorSmsChannelTestNotifiable; + $notification = new NotificationSmsFactorSmsChannelTestCustomGsmsmsidNotification(); + $notifiable = new NotificationSmsFactorSmsChannelTestNotifiable(); $channel = new SmsFactorSmsChannel(); @@ -133,11 +132,11 @@ public function testSmsIsSentViaSmsFactorWithCustomGsmsmsid() $mock->shouldReceive('send') ->with( [ - 'to' => '5555555555', - 'text' => 'this is my message', - 'delay' => null, + 'to' => '5555555555', + 'text' => 'this is my message', + 'delay' => null, 'pushtype' => null, - 'sender' => null, + 'sender' => null, 'gsmsmsid' => 'my-custom-id', ] ) @@ -198,4 +197,4 @@ public function routeNotificationForSmsFactor($notification) { return $this->phone_number; } -} \ No newline at end of file +}