Skip to content

Commit

Permalink
Remove actions
Browse files Browse the repository at this point in the history
  • Loading branch information
3m1n3nc3 committed Feb 6, 2024
1 parent d7cf2d1 commit 8a767d9
Show file tree
Hide file tree
Showing 16 changed files with 34 additions and 100 deletions.
48 changes: 0 additions & 48 deletions .github/workflows/php.yml

This file was deleted.

4 changes: 2 additions & 2 deletions src/Exceptions/CouldNotSendNotification.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@ public static function respondedWithAnError(Exception $exception)
public static function invalidMessage()
{
return new static(
'The toKudiSms() method only accepts instances of ' .
KudiSmsMessage::class . ' or ' .
'The toKudiSms() method only accepts instances of '.
KudiSmsMessage::class.' or '.
KudiSmsVoiceMessage::class
);
}
Expand Down
19 changes: 9 additions & 10 deletions src/KudiNotification.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,22 +15,22 @@ class KudiNotification

public string $apiKey;

public function __construct(?string $senderId = null, ?string $apiKey = null, ?string $callerId = null)
public function __construct(string $senderId = null, string $apiKey = null, string $callerId = null)
{
$this->senderId = $senderId ?: config('kudi-notification.sender_id');
$this->callerId = $callerId ?: config('kudi-notification.caller_id');
$this->apiKey = $apiKey ?: config('kudi-notification.api_key');
$this->senderId = $senderId ?: config('kudi-notification.sender_id');
$this->callerId = $callerId ?: config('kudi-notification.caller_id');
$this->apiKey = $apiKey ?: config('kudi-notification.api_key');

if (!$this->apiKey) {
if (! $this->apiKey) {
throw InvalidConfigException::missingToken();
}

if (!$this->senderId && !$this->callerId) {
if (! $this->senderId && ! $this->callerId) {
throw InvalidConfigException::missingConfig();
}
}

public function sms(?string $senderId = null, ?string $apiKey = null): SmsSender
public function sms(string $senderId = null, string $apiKey = null): SmsSender
{
if (empty($callerId) && empty($this->senderId)) {
throw CouldNotSendNotification::missingFrom();
Expand All @@ -42,7 +42,7 @@ public function sms(?string $senderId = null, ?string $apiKey = null): SmsSender
);
}

public function voice(?string $callerId = null, ?string $apiKey = null): VoiceSender
public function voice(string $callerId = null, string $apiKey = null): VoiceSender
{
if (empty($callerId) && empty($this->callerId) && empty($this->senderId)) {
throw CouldNotSendNotification::missingFrom();
Expand All @@ -57,10 +57,9 @@ public function voice(?string $callerId = null, ?string $apiKey = null): VoiceSe
/**
* Send a KudiMessage to the a phone number.
*
* @param KudiMessage $message
* @param string|null $to
*
* @return mixed
*
* @throws CouldNotSendNotification
*/
public function sendMessage(KudiMessage $message, ?string $to)
Expand Down
15 changes: 6 additions & 9 deletions src/KudiSmsChannel.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,6 @@ class KudiSmsChannel
{
/**
* KudiSmsChannel constructor.
*
* @param \ToneflixCode\KudiSmsNotification\KudiNotification $kudi
* @param \Illuminate\Contracts\Events\Dispatcher $events
*/
public function __construct(
protected KudiNotification $kudi,
Expand All @@ -26,10 +23,10 @@ public function __construct(
/**
* Get the address to send a notification to.
*
* @param mixed $notifiable
* @param Notification|null $notification
*
* @param mixed $notifiable
* @param Notification|null $notification
* @return mixed
*
* @throws CouldNotSendNotification
*/
protected function getTo($notifiable, $notification = null)
Expand All @@ -50,10 +47,9 @@ protected function getTo($notifiable, $notification = null)
/**
* Send the given notification.
*
* @param mixed $notifiable
* @param Notification $notification
*
* @param mixed $notifiable
* @return mixed
*
* @throws Exception
*/
public function send($notifiable, Notification $notification)
Expand All @@ -69,6 +65,7 @@ public function send($notifiable, Notification $notification)
if (! $message instanceof KudiMessage) {
throw CouldNotSendNotification::invalidMessage();
}

return $this->kudi->sendMessage($message, $to);
} catch (Exception $exception) {
$event = new NotificationFailed(
Expand Down
4 changes: 0 additions & 4 deletions src/KudiSmsMessage.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,6 @@ class KudiSmsMessage extends KudiMessage

/**
* Create a new message instance.
*
* @param string $message
*/
public function __construct(string $message = '')
{
Expand All @@ -22,7 +20,6 @@ public function __construct(string $message = '')
/**
* Set the message.
*
* @param string $message
* @return $this
*/
public function message(string $message): self
Expand All @@ -35,7 +32,6 @@ public function message(string $message): self
/**
* Set the message senderId.
*
* @param string $senderId
* @return $this
*/
public function senderId(string $senderId): self
Expand Down
4 changes: 2 additions & 2 deletions src/KudiSmsProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ class KudiSmsProvider extends ServiceProvider
public function boot()
{
$this->publishes([
__DIR__ . '/../config/config.php' => config_path('kudi-notification.php'),
__DIR__.'/../config/config.php' => config_path('kudi-notification.php'),
], 'config');
}

Expand All @@ -22,7 +22,7 @@ public function boot()
public function register()
{
// Automatically apply the package configuration
$this->mergeConfigFrom(__DIR__ . '/../config/config.php', 'kudi-notification');
$this->mergeConfigFrom(__DIR__.'/../config/config.php', 'kudi-notification');

// Register the main class to use with the facade
$this->app->singleton('kudi-notification', function () {
Expand Down
2 changes: 0 additions & 2 deletions src/KudiSmsTTSMessage.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ class KudiSmsTTSMessage extends KudiMessage
/**
* Set the message.
*
* @param string $message
* @return $this
*/
public function message(string $message): self
Expand All @@ -25,7 +24,6 @@ public function message(string $message): self
/**
* Set the message callerId.
*
* @param string $callerId
* @return $this
*/
public function callerId(string $callerId): self
Expand Down
2 changes: 0 additions & 2 deletions src/KudiSmsVoiceMessage.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ class KudiSmsVoiceMessage extends KudiMessage
/**
* Set the message url.
*
* @param string $url
* @return $this
*/
public function url(string $url): self
Expand All @@ -27,7 +26,6 @@ public function url(string $url): self
/**
* Set the message callerId.
*
* @param string $callerId
* @return $this
*/
public function callerId(string $callerId): self
Expand Down
2 changes: 1 addition & 1 deletion tests/Feature/SendSmsTest.php
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
<?php

use ToneflixCode\KudiSmsNotification\Tests\Notifications\SendSms;
use ToneflixCode\KudiSmsNotification\Tests\Models\User;
use ToneflixCode\KudiSmsNotification\Tests\Notifications\SendCall;
use ToneflixCode\KudiSmsNotification\Tests\Notifications\SendSms;
use ToneflixCode\KudiSmsNotification\Tests\Notifications\SendTtsCall;

test('user can recieve sms', function () {
Expand Down
6 changes: 2 additions & 4 deletions tests/Notifications/SendCall.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,7 @@ public function __construct($message = null)
/**
* Get the notification's delivery channels.
*
* @param mixed $notifiable notifiable
*
* @param mixed $notifiable notifiable
* @return array
*/
public function via($notifiable)
Expand All @@ -39,8 +38,7 @@ public function via($notifiable)
/**
* Get the sms representation of the notification.
*
* @param mixed $notifiable notifiable
*
* @param mixed $notifiable notifiable
* @return \NotificationChannels\Twilio\TwilioSmsMessage
*/
public function toKudiSms($notifiable)
Expand Down
8 changes: 3 additions & 5 deletions tests/Notifications/SendSms.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,7 @@ public function __construct($message = null)
/**
* Get the notification's delivery channels.
*
* @param mixed $notifiable notifiable
*
* @param mixed $notifiable notifiable
* @return array
*/
public function via($notifiable)
Expand All @@ -39,12 +38,11 @@ public function via($notifiable)
/**
* Get the sms representation of the notification.
*
* @param mixed $notifiable notifiable
*
* @param mixed $notifiable notifiable
* @return \NotificationChannels\Twilio\TwilioSmsMessage
*/
public function toKudiSms($notifiable)
{
return (new KudiSmsMessage())->message($this->message);
}
}
}
6 changes: 2 additions & 4 deletions tests/Notifications/SendTtsCall.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,7 @@ public function __construct($message = null)
/**
* Get the notification's delivery channels.
*
* @param mixed $notifiable notifiable
*
* @param mixed $notifiable notifiable
* @return array
*/
public function via($notifiable)
Expand All @@ -39,8 +38,7 @@ public function via($notifiable)
/**
* Get the sms representation of the notification.
*
* @param mixed $notifiable notifiable
*
* @param mixed $notifiable notifiable
* @return \NotificationChannels\Twilio\TwilioSmsMessage
*/
public function toKudiSms($notifiable)
Expand Down
2 changes: 1 addition & 1 deletion tests/Pest.php
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,6 @@
function loadEnv()
{
// Load the .env file
$dotenv = \Dotenv\Dotenv::createImmutable(__DIR__ . '/..');
$dotenv = \Dotenv\Dotenv::createImmutable(__DIR__.'/..');
$dotenv->safeLoad();
}
8 changes: 4 additions & 4 deletions tests/TestCase.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@

use Illuminate\Database\Eloquent\Factories\Factory;
use Illuminate\Foundation\Testing\RefreshDatabase;
use ToneflixCode\KudiSmsNotification\KudiSmsProvider;
use Orchestra\Testbench\TestCase as Orchestra;
use ToneflixCode\KudiSmsNotification\KudiSmsProvider;

abstract class TestCase extends Orchestra
{
Expand Down Expand Up @@ -42,7 +42,7 @@ public function getEnvironmentSetUp($app)
$_SERVER['KUDISMS_TEST_NUMBERS'] ?? $_ENV['KUDISMS_TEST_NUMBERS'] ?? ''
);

$migration = include __DIR__ . '/database/migrations/create_users_tables.php';
$migration = include __DIR__.'/database/migrations/create_users_tables.php';
$migration->up();
}

Expand All @@ -51,10 +51,10 @@ protected function setUp(): void
parent::setUp();

Factory::guessFactoryNamesUsing(
fn (string $modelName) => 'ToneflixCode\\KudiSmsNotification\\Tests\\Database\\Factories\\' .
fn (string $modelName) => 'ToneflixCode\\KudiSmsNotification\\Tests\\Database\\Factories\\'.
class_basename(
$modelName
) . 'Factory'
).'Factory'
);
}

Expand Down
2 changes: 1 addition & 1 deletion tests/database/factories/UserFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@

namespace ToneflixCode\KudiSmsNotification\Tests\Database\Factories;

use ToneflixCode\KudiSmsNotification\Tests\Models\User;
use Illuminate\Database\Eloquent\Factories\Factory;
use Illuminate\Support\Str;
use ToneflixCode\KudiSmsNotification\Tests\Models\User;

class UserFactory extends Factory
{
Expand Down
2 changes: 1 addition & 1 deletion tests/database/migrations/create_users_tables.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;

return new class () extends Migration
return new class() extends Migration
{
public function up(): void
{
Expand Down

0 comments on commit 8a767d9

Please sign in to comment.