From 829e205b8c536e792c85545f370cc89d91a2f457 Mon Sep 17 00:00:00 2001 From: StyleCI Bot Date: Fri, 1 Sep 2023 16:58:30 +0000 Subject: [PATCH] Apply fixes from StyleCI --- config/sms.php | 12 ++++---- database/factories/SmsReportFactory.php | 12 ++++---- ...1_10_03_164841_create_sms_report_table.php | 5 ++-- routes/web.php | 2 +- src/Abstracts/Driver.php | 21 ++++++++------ src/Channels/SmsChannel.php | 17 +++++------ src/Channels/VoiceCallChannel.php | 17 +++++------ src/Contracts/Driver.php | 8 ++++-- src/Drivers/Avanak.php | 8 +++--- src/Drivers/FakeSmsSender.php | 4 +-- src/Drivers/Kavenegar.php | 4 +-- src/Drivers/Magfa.php | 16 +++++------ src/Drivers/SmsOnline.php | 22 +++++++-------- src/Facades/Sms.php | 4 +-- src/Facades/VoiceCall.php | 2 +- src/Http/Controllers/Web/SmsController.php | 9 +++--- src/Listeners/DbLogListener.php | 3 +- src/Message.php | 15 +++++----- src/Models/SmsReport.php | 28 ++++++++++--------- src/Providers/EventServiceProvider.php | 2 +- src/Providers/SmsProvider.php | 7 +++-- src/Routes/web.php | 2 +- src/SmsManager.php | 7 +++-- src/VoiceCallManager.php | 7 +++-- tests/Feature/Drivers/FakeSmsSenderTest.php | 8 +++--- tests/Feature/Drivers/KavenegarTest.php | 2 +- tests/Feature/SmsTest.php | 10 +++---- tests/Feature/VoiceCallTest.php | 6 ++-- tests/Feature/Web/SmsControllerTest.php | 1 - tests/TestCase.php | 12 ++++---- 30 files changed, 143 insertions(+), 130 deletions(-) diff --git a/config/sms.php b/config/sms.php index 4aaa595..b56fa5b 100644 --- a/config/sms.php +++ b/config/sms.php @@ -12,7 +12,7 @@ | You can switch to a different driver at runtime. | */ - 'driver' => env('SMS_DRIVER', 'fake'), + 'driver' => env('SMS_DRIVER', 'fake'), 'driver_voice_call' => 'fake', /* @@ -30,26 +30,26 @@ 'from' => '1111111111', ], 'kavenegar' => [ - 'from' => '', + 'from' => '', 'apiKey' => env('KAVENEGAR_API_KEY'), ], 'magfa' => [ 'username' => env('SMS_MAGFA_USERNAME'), 'password' => env('SMS_MAGFA_PASSWORD'), - 'domain' => env('SMS_MAGFA_DOMAIN'), - 'from' => env('SMS_MAGFA_SENDER_NUMBER'), + 'domain' => env('SMS_MAGFA_DOMAIN'), + 'from' => env('SMS_MAGFA_SENDER_NUMBER'), 'wsdl_url' => 'https://sms.magfa.com/api/soap/sms/v2/server?wsdl', ], 'smsonline' => [ 'username' => env('SMS_ONLINE_USERNAME'), 'password' => env('SMS_ONLINE_PASSWORD'), - 'from' => env('SMS_ONLINE_SENDER_NUMBER'), + 'from' => env('SMS_ONLINE_SENDER_NUMBER'), 'wsdl_url' => 'http://www.linepayamak.ir/Post/Send.asmx?wsdl', ], 'avanak' => [ 'username' => env('VOICE_AVANAK_USERNAME'), 'password' => env('VOICE_AVANAK_PASSWORD'), - 'from' => env('VOICE_AVANAK_SENDER_NUMBER'), + 'from' => env('VOICE_AVANAK_SENDER_NUMBER'), 'wsdl_url' => 'http://portal.avanak.ir/webservice3.asmx?WSDL', ], ], diff --git a/database/factories/SmsReportFactory.php b/database/factories/SmsReportFactory.php index 0eb2adc..49cf3ea 100644 --- a/database/factories/SmsReportFactory.php +++ b/database/factories/SmsReportFactory.php @@ -2,8 +2,8 @@ namespace HoomanMirghasemi\Sms\Database\Factories; -use Illuminate\Database\Eloquent\Factories\Factory; use HoomanMirghasemi\Sms\Models\SmsReport; +use Illuminate\Database\Eloquent\Factories\Factory; class SmsReportFactory extends Factory { @@ -24,12 +24,12 @@ public function definition() $drivers = ['kavehnegar', 'fakesmssender']; return [ - 'mobile' => '+98'.substr($this->faker->mobileNumber(), 1), - 'message' => $this->faker->paragraph(), - 'from' => $drivers[array_rand($drivers)], - 'number' => $this->faker->phoneNumber, + 'mobile' => '+98'.substr($this->faker->mobileNumber(), 1), + 'message' => $this->faker->paragraph(), + 'from' => $drivers[array_rand($drivers)], + 'number' => $this->faker->phoneNumber, 'web_service_response' => $this->faker->paragraph(), - 'success' => $this->faker->boolean, + 'success' => $this->faker->boolean, ]; } } diff --git a/database/migrations/2021_10_03_164841_create_sms_report_table.php b/database/migrations/2021_10_03_164841_create_sms_report_table.php index 1340b64..5fc5668 100644 --- a/database/migrations/2021_10_03_164841_create_sms_report_table.php +++ b/database/migrations/2021_10_03_164841_create_sms_report_table.php @@ -1,13 +1,12 @@ name('sms.index'); diff --git a/src/Abstracts/Driver.php b/src/Abstracts/Driver.php index cc5d8c6..6be3031 100644 --- a/src/Abstracts/Driver.php +++ b/src/Abstracts/Driver.php @@ -2,11 +2,11 @@ namespace HoomanMirghasemi\Sms\Abstracts; -use Illuminate\Support\Facades\Event; use HoomanMirghasemi\Sms\Contracts\Driver as DriverContract; use HoomanMirghasemi\Sms\Contracts\Message; use HoomanMirghasemi\Sms\Events\ProviderConnectionFailedEvent; use HoomanMirghasemi\Sms\Events\SmsSentEvent; +use Illuminate\Support\Facades\Event; abstract class Driver implements DriverContract { @@ -18,21 +18,21 @@ abstract class Driver implements DriverContract protected bool $serviceActive = true; /** - * Recipient (mobile number in E164 format) + * Recipient (mobile number in E164 format). * * @param string */ protected string $recipient; /** - * Sender number + * Sender number. * * @param string */ protected string $from; /** - * Message + * Message. * * @var Message|string */ @@ -55,9 +55,10 @@ abstract class Driver implements DriverContract public $callBackAfterSend; /** - * Add recipient (phone or mobile numbers) + * Add recipient (phone or mobile numbers). + * + * @param string $recipient * - * @param string $recipient * @return self */ public function to(string $recipient): self @@ -78,7 +79,7 @@ public function getRecipient(): string } /** - * Get sender number (from attribute) + * Get sender number (from attribute). * * @return string */ @@ -90,7 +91,8 @@ public function getSenderNumber(): string /** * Set related message. * - * @param Message $message + * @param Message $message + * * @return self */ public function message(Message|string $message): self @@ -139,6 +141,7 @@ public function getWebServiceResponce(): string * note: It do not only work correctly when use Notification Queueable. * * @param $function + * * @return $this */ public function setCallBack(callable $function): self @@ -150,7 +153,7 @@ public function setCallBack(callable $function): self /** * Each driver should call this parent method at end of own send. - * This fire SmsSentEvent + * This fire SmsSentEvent. * * @see SmsSentEvent * diff --git a/src/Channels/SmsChannel.php b/src/Channels/SmsChannel.php index c597bf7..c002a2f 100644 --- a/src/Channels/SmsChannel.php +++ b/src/Channels/SmsChannel.php @@ -3,25 +3,26 @@ namespace HoomanMirghasemi\Sms\Channels; use Exception; -use Illuminate\Notifications\Notification; use HoomanMirghasemi\Sms\Abstracts\Driver; use HoomanMirghasemi\Sms\SmsManager; +use Illuminate\Notifications\Notification; class SmsChannel { /** * Send notification. * - * @param $notifiable - * @param Notification $notification - * @return void + * @param $notifiable + * @param Notification $notification * * @throws Exception + * + * @return void */ public function send($notifiable, Notification $notification): void { $manager = $notification->toSms($notifiable); - if (! is_null($manager)) { + if (!is_null($manager)) { $this->validate($manager); $manager->send(); } @@ -30,13 +31,13 @@ public function send($notifiable, Notification $notification): void /** * Validate sms. * - * @return void - * * @throws Exception + * + * @return void */ protected function validate($manager): void { - if (! $manager instanceof SmsManager && ! $manager instanceof Driver) { + if (!$manager instanceof SmsManager && !$manager instanceof Driver) { throw new Exception('Invalid data for sms notification.'); } } diff --git a/src/Channels/VoiceCallChannel.php b/src/Channels/VoiceCallChannel.php index e2787e0..f7c167c 100644 --- a/src/Channels/VoiceCallChannel.php +++ b/src/Channels/VoiceCallChannel.php @@ -3,25 +3,26 @@ namespace HoomanMirghasemi\Sms\Channels; use Exception; -use Illuminate\Notifications\Notification; use HoomanMirghasemi\Sms\Abstracts\Driver; use HoomanMirghasemi\Sms\VoiceCallManager; +use Illuminate\Notifications\Notification; class VoiceCallChannel { /** * Send notification. * - * @param $notifiable - * @param Notification $notification - * @return void + * @param $notifiable + * @param Notification $notification * * @throws Exception + * + * @return void */ public function send($notifiable, Notification $notification): void { $manager = $notification->toVoiceCall($notifiable); - if (! is_null($manager)) { + if (!is_null($manager)) { $this->validate($manager); $manager->send(); } @@ -30,13 +31,13 @@ public function send($notifiable, Notification $notification): void /** * Validate sms. * - * @return void - * * @throws Exception + * + * @return void */ protected function validate($manager): void { - if (! $manager instanceof VoiceCallManager && ! $manager instanceof Driver) { + if (!$manager instanceof VoiceCallManager && !$manager instanceof Driver) { throw new Exception('Invalid data for voice call notification.'); } } diff --git a/src/Contracts/Driver.php b/src/Contracts/Driver.php index 2a94eb9..c3ce271 100644 --- a/src/Contracts/Driver.php +++ b/src/Contracts/Driver.php @@ -5,9 +5,10 @@ interface Driver { /** - * Add recipient (mobile numbers) + * Add recipient (mobile numbers). + * + * @param string $recipient * - * @param string $recipient * @return self */ public function to(string $recipient): self; @@ -15,7 +16,8 @@ public function to(string $recipient): self; /** * Set related message. * - * @param Message $message + * @param Message $message + * * @return self */ public function message(Message $message): self; diff --git a/src/Drivers/Avanak.php b/src/Drivers/Avanak.php index 40f57d1..ffcef14 100644 --- a/src/Drivers/Avanak.php +++ b/src/Drivers/Avanak.php @@ -3,10 +3,10 @@ namespace HoomanMirghasemi\Sms\Drivers; use Exception; +use HoomanMirghasemi\Sms\Abstracts\Driver; use Illuminate\Support\Facades\Log; use SoapClient; use SoapFault; -use HoomanMirghasemi\Sms\Abstracts\Driver; class Avanak extends Driver { @@ -35,14 +35,14 @@ public function __construct(protected array $settings) */ public function send(): bool { - if (! $this->serviceActive) { + if (!$this->serviceActive) { parent::failedConnectToProvider(); return false; } $this->params['text'] = $this->getMessage(); $this->params['number'] = $this->recipient; - if (! str_starts_with($this->params['number'], '+98')) { + if (!str_starts_with($this->params['number'], '+98')) { return false; } // for sending to avanak change number format @@ -72,7 +72,7 @@ public function send(): bool */ public function getBalance(): string { - if (! $this->serviceActive) { + if (!$this->serviceActive) { return 'وب سرویس آوانک با مشکل مواجه شده.'; } diff --git a/src/Drivers/FakeSmsSender.php b/src/Drivers/FakeSmsSender.php index a89b3c7..0472610 100644 --- a/src/Drivers/FakeSmsSender.php +++ b/src/Drivers/FakeSmsSender.php @@ -27,7 +27,7 @@ public function __construct(protected array $settings) */ public function send(): bool { - if (! self::$successSend) { + if (!self::$successSend) { $this->webserviceResponse = 'An error happened !'; $this->success = false; } else { @@ -39,7 +39,7 @@ public function send(): bool } /** - * Return fake balance :D + * Return fake balance :D. * * @return string */ diff --git a/src/Drivers/Kavenegar.php b/src/Drivers/Kavenegar.php index 2110312..54d7613 100644 --- a/src/Drivers/Kavenegar.php +++ b/src/Drivers/Kavenegar.php @@ -2,8 +2,8 @@ namespace HoomanMirghasemi\Sms\Drivers; -use Kavenegar\KavenegarApi; use HoomanMirghasemi\Sms\Abstracts\Driver; +use Kavenegar\KavenegarApi; class Kavenegar extends Driver { @@ -41,7 +41,6 @@ public function send(): bool null, $token10, $token20 - ); } else { $result = $this->kavenegarApi->Send(null, $this->recipient, $this->message->toString()); @@ -65,6 +64,7 @@ private function replaceExtraSpace($string, $maxSpace) if ($spaceCount > $maxSpace) { $string = strrev(preg_replace('/ /', '-', strrev($string), $spaceCount - $maxSpace)); } + return $string; } } diff --git a/src/Drivers/Magfa.php b/src/Drivers/Magfa.php index 4e224ee..ce876b0 100644 --- a/src/Drivers/Magfa.php +++ b/src/Drivers/Magfa.php @@ -3,11 +3,11 @@ namespace HoomanMirghasemi\Sms\Drivers; use Exception; +use HoomanMirghasemi\Sms\Abstracts\Driver; use Illuminate\Support\Facades\App; use Illuminate\Support\Facades\Log; use SoapClient; use SoapFault; -use HoomanMirghasemi\Sms\Abstracts\Driver; class Magfa extends Driver { @@ -28,7 +28,7 @@ public function __construct(protected array $settings) */ public function send(): bool { - if (! $this->serviceActive) { + if (!$this->serviceActive) { parent::failedConnectToProvider(); return false; @@ -53,7 +53,7 @@ public function send(): bool */ public function getBalance(): string { - if (! $this->serviceActive) { + if (!$this->serviceActive) { return 'وب سرویس مگفا با مشکل مواجه شده.'; } @@ -75,11 +75,11 @@ private function tryConnectToProvider(): void { try { $this->soapClient = new SoapClient(data_get($this->settings, 'wsdl_url'), [ - 'login' => data_get($this->settings, 'username').'/'.data_get($this->settings, 'domain'), - 'password' => data_get($this->settings, 'password'), - 'cache_wsdl' => WSDL_CACHE_NONE, // -No WSDL Cache + 'login' => data_get($this->settings, 'username').'/'.data_get($this->settings, 'domain'), + 'password' => data_get($this->settings, 'password'), + 'cache_wsdl' => WSDL_CACHE_NONE, // -No WSDL Cache 'compression' => (SOAP_COMPRESSION_ACCEPT | SOAP_COMPRESSION_GZIP | 5), // -Compression * - 'trace' => App::environment(['local', 'staging', 'testing']), // -Optional (debug) + 'trace' => App::environment(['local', 'staging', 'testing']), // -Optional (debug) ]); } catch (SoapFault $soapFault) { Log::error('magfa sms code: '.$soapFault->getCode().' message: '.$soapFault->getMessage()); @@ -88,7 +88,7 @@ private function tryConnectToProvider(): void } /** - * Return error messages for SmsMagfa + * Return error messages for SmsMagfa. * * @return array */ diff --git a/src/Drivers/SmsOnline.php b/src/Drivers/SmsOnline.php index f9d14a6..39069ad 100644 --- a/src/Drivers/SmsOnline.php +++ b/src/Drivers/SmsOnline.php @@ -3,9 +3,9 @@ namespace HoomanMirghasemi\Sms\Drivers; use Exception; +use HoomanMirghasemi\Sms\Abstracts\Driver; use Illuminate\Support\Facades\Log; use SoapClient; -use HoomanMirghasemi\Sms\Abstracts\Driver; class SmsOnline extends Driver { @@ -26,7 +26,7 @@ public function __construct(protected array $settings) */ public function send(): bool { - if (! $this->serviceActive) { + if (!$this->serviceActive) { parent::failedConnectToProvider(); return false; @@ -34,13 +34,13 @@ public function send(): bool $response = $this->soapClient->SendSms([ 'username' => data_get($this->settings, 'username'), 'password' => data_get($this->settings, 'password'), // Credientials - 'from' => data_get($this->settings, 'from'), - 'to' => [str_replace('+98', '', $this->recipient)], - 'text' => $this->getMessage(), - 'isflash' => false, - 'udh' => '', - 'recId' => [0], - 'status' => [0], + 'from' => data_get($this->settings, 'from'), + 'to' => [str_replace('+98', '', $this->recipient)], + 'text' => $this->getMessage(), + 'isflash' => false, + 'udh' => '', + 'recId' => [0], + 'status' => [0], ]); if ($response->SendSmsResult != 1) { $this->webserviceResponse = 'An error occured'; @@ -61,7 +61,7 @@ public function send(): bool */ public function getBalance(): string { - if (! $this->serviceActive) { + if (!$this->serviceActive) { return 'ماژول پیامک آنلاین اس ام اس برنامه غیر فعال می باشد.'; } @@ -78,7 +78,7 @@ public function getBalance(): string } /** - * Return error messages for SmsMagfa + * Return error messages for SmsMagfa. * * @return array */ diff --git a/src/Facades/Sms.php b/src/Facades/Sms.php index 68b7d1c..bba487e 100644 --- a/src/Facades/Sms.php +++ b/src/Facades/Sms.php @@ -2,11 +2,11 @@ namespace HoomanMirghasemi\Sms\Facades; -use Illuminate\Support\Facades\Facade; use HoomanMirghasemi\Sms\Contracts\Message; +use Illuminate\Support\Facades\Facade; /** - * Class Sms + * Class Sms. * * @method static to(string $mobileNumber); * @method static message(Message|string $message); diff --git a/src/Facades/VoiceCall.php b/src/Facades/VoiceCall.php index 0eaf89f..16c5349 100644 --- a/src/Facades/VoiceCall.php +++ b/src/Facades/VoiceCall.php @@ -5,7 +5,7 @@ use Illuminate\Support\Facades\Facade; /** - * Class VoiceCall + * Class VoiceCall. * * @method static to(string $mobileNumber); */ diff --git a/src/Http/Controllers/Web/SmsController.php b/src/Http/Controllers/Web/SmsController.php index 78ec801..680a7fc 100644 --- a/src/Http/Controllers/Web/SmsController.php +++ b/src/Http/Controllers/Web/SmsController.php @@ -2,29 +2,30 @@ namespace HoomanMirghasemi\Sms\Http\Controllers\Web; +use HoomanMirghasemi\Sms\Models\SmsReport; use Illuminate\Contracts\Foundation\Application; use Illuminate\Contracts\View\Factory; use Illuminate\Contracts\View\View; use Illuminate\Pagination\Paginator; use Illuminate\Routing\Controller; -use Illuminate\Support\Facades\App; -use HoomanMirghasemi\Sms\Models\SmsReport; class SmsController extends Controller { /** * Show sms in paginated list. - * This page only use for develop + * This page only use for develop. * * @return Factory|View|Application */ public function index(): Factory|View|Application { /** - * Action information + * Action information. * * @get(/sms/get-sms-list) + * * @name(sms.getList) the name + * * @middlewares(web) */ if (config('app.env') == 'production') { diff --git a/src/Listeners/DbLogListener.php b/src/Listeners/DbLogListener.php index 382bb3f..f465443 100644 --- a/src/Listeners/DbLogListener.php +++ b/src/Listeners/DbLogListener.php @@ -11,7 +11,8 @@ class DbLogListener /** * Handle the event. * - * @param object $event + * @param object $event + * * @return void */ public function handle(SmsEvent $event): void diff --git a/src/Message.php b/src/Message.php index f8b91cf..8719ef7 100644 --- a/src/Message.php +++ b/src/Message.php @@ -7,7 +7,7 @@ class Message implements MessageContract { /** - * Plain text message + * Plain text message. * * @param string */ @@ -20,13 +20,13 @@ class Message implements MessageContract */ protected array $template = [ 'identifier' => null, - 'params' => null, + 'params' => null, ]; /** - * Message constructor + * Message constructor. * - * @param string $message + * @param string $message */ public function __construct(string $message) { @@ -46,8 +46,9 @@ public function toString(): string /** * Retrieve string format of message. * - * @param string $templateIdentifier - * @param array $params + * @param string $templateIdentifier + * @param array $params + * * @return self */ public function useTemplateIfSupports(string $templateIdentifier, array $params = []): self @@ -63,7 +64,7 @@ public function useTemplateIfSupports(string $templateIdentifier, array $params */ public function usesTemplate(): bool { - return ! is_null($this->template['identifier']); + return !is_null($this->template['identifier']); } /** diff --git a/src/Models/SmsReport.php b/src/Models/SmsReport.php index 9c3e9b4..3f9460e 100644 --- a/src/Models/SmsReport.php +++ b/src/Models/SmsReport.php @@ -2,21 +2,21 @@ namespace HoomanMirghasemi\Sms\Models; -use Illuminate\Database\Eloquent\Factories\HasFactory; use HoomanMirghasemi\Sms\Database\Factories\SmsReportFactory; +use Illuminate\Database\Eloquent\Factories\HasFactory; /** - * App\Models\SmsReport + * App\Models\SmsReport. * - * @property int $id identifier - * @property string|null $mobile mobile number sms sent to - * @property string|null $message sms text - * @property string|null $from name of sms sender provider - * @property string|null $number sender number - * @property string|null $web_service_response sms provider webservice response - * @property bool $success boolean: successful webservice response or fail - * @property \Illuminate\Support\Carbon|null $created_at when this record created - * @property \Illuminate\Support\Carbon|null $updated_at the record last updated time + * @property int $id identifier + * @property string|null $mobile mobile number sms sent to + * @property string|null $message sms text + * @property string|null $from name of sms sender provider + * @property string|null $number sender number + * @property string|null $web_service_response sms provider webservice response + * @property bool $success boolean: successful webservice response or fail + * @property \Illuminate\Support\Carbon|null $created_at when this record created + * @property \Illuminate\Support\Carbon|null $updated_at the record last updated time * * @method static \Illuminate\Database\Eloquent\Builder|SmsReport newModelQuery() * @method static \Illuminate\Database\Eloquent\Builder|SmsReport newQuery() @@ -31,13 +31,15 @@ class SmsReport extends \Illuminate\Database\Eloquent\Model public const TABLE = 'sms_reports'; /** - * The model table name in database + * The model table name in database. + * * @var string */ protected $table = self::TABLE; /** * An array of attribute names that are mass assignable in the database. + * * @var string[] */ protected $fillable = [ @@ -46,7 +48,7 @@ class SmsReport extends \Illuminate\Database\Eloquent\Model 'from', 'number', 'web_service_response', - 'success' + 'success', ]; protected $casts = [ diff --git a/src/Providers/EventServiceProvider.php b/src/Providers/EventServiceProvider.php index baa166d..5562bbd 100644 --- a/src/Providers/EventServiceProvider.php +++ b/src/Providers/EventServiceProvider.php @@ -2,10 +2,10 @@ namespace HoomanMirghasemi\Sms\Providers; -use Illuminate\Foundation\Support\Providers\EventServiceProvider as ServiceProvider; use HoomanMirghasemi\Sms\Events\ProviderConnectionFailedEvent; use HoomanMirghasemi\Sms\Events\SmsSentEvent; use HoomanMirghasemi\Sms\Listeners\DbLogListener; +use Illuminate\Foundation\Support\Providers\EventServiceProvider as ServiceProvider; class EventServiceProvider extends ServiceProvider { diff --git a/src/Providers/SmsProvider.php b/src/Providers/SmsProvider.php index f24492d..0f29b0f 100644 --- a/src/Providers/SmsProvider.php +++ b/src/Providers/SmsProvider.php @@ -2,12 +2,12 @@ namespace HoomanMirghasemi\Sms\Providers; -use Illuminate\Support\ServiceProvider; -use Kavenegar\KavenegarApi; use HoomanMirghasemi\Sms\Drivers\FakeSmsSender; use HoomanMirghasemi\Sms\Drivers\Kavenegar; use HoomanMirghasemi\Sms\SmsManager; use HoomanMirghasemi\Sms\VoiceCallManager; +use Illuminate\Support\ServiceProvider; +use Kavenegar\KavenegarApi; class SmsProvider extends ServiceProvider { @@ -74,7 +74,8 @@ public function loadViews(): self private function mergeConfigFiles(): self { $this->mergeConfigFrom( - __DIR__.'/../../config/sms.php', 'sms' + __DIR__.'/../../config/sms.php', + 'sms' ); return $this; diff --git a/src/Routes/web.php b/src/Routes/web.php index 7546840..30e404e 100644 --- a/src/Routes/web.php +++ b/src/Routes/web.php @@ -11,8 +11,8 @@ | */ -use Illuminate\Support\Facades\Route; use HoomanMirghasemi\Sms\Http\Controllers\SmsController; +use Illuminate\Support\Facades\Route; Route::prefix('laravel/sms')->group(function () { Route::get('get-sms-list', [SmsController::class, 'getList'])->name('sms.getList'); diff --git a/src/SmsManager.php b/src/SmsManager.php index 5b0bb66..074e2b0 100644 --- a/src/SmsManager.php +++ b/src/SmsManager.php @@ -2,10 +2,10 @@ namespace HoomanMirghasemi\Sms; -use Illuminate\Support\Facades\App; -use Illuminate\Support\Manager; use HoomanMirghasemi\Sms\Drivers\FakeSmsSender; use HoomanMirghasemi\Sms\Drivers\Kavenegar; +use Illuminate\Support\Facades\App; +use Illuminate\Support\Manager; class SmsManager extends Manager { @@ -46,7 +46,8 @@ public function getDefaultDriver(): string /** * Set the default sms driver name. * - * @param string $name + * @param string $name + * * @return void */ public function setDefaultDriver(string $name): void diff --git a/src/VoiceCallManager.php b/src/VoiceCallManager.php index ee2098d..680815a 100644 --- a/src/VoiceCallManager.php +++ b/src/VoiceCallManager.php @@ -2,10 +2,10 @@ namespace HoomanMirghasemi\Sms; -use Illuminate\Support\Facades\App; -use Illuminate\Support\Manager; use HoomanMirghasemi\Sms\Drivers\Avanak; use HoomanMirghasemi\Sms\Drivers\FakeSmsSender; +use Illuminate\Support\Facades\App; +use Illuminate\Support\Manager; class VoiceCallManager extends Manager { @@ -46,7 +46,8 @@ public function getDefaultDriver(): string /** * Set the default sms driver name. * - * @param string $name + * @param string $name + * * @return void */ public function setDefaultDriver($name): void diff --git a/tests/Feature/Drivers/FakeSmsSenderTest.php b/tests/Feature/Drivers/FakeSmsSenderTest.php index 7135073..3deb175 100644 --- a/tests/Feature/Drivers/FakeSmsSenderTest.php +++ b/tests/Feature/Drivers/FakeSmsSenderTest.php @@ -21,10 +21,10 @@ public function testFailedSendSms() $this->assertFalse($result); $this->assertDatabaseHas(SmsReport::class, [ - 'mobile' => $this->mobile, + 'mobile' => $this->mobile, 'success' => false, 'message' => 'Test fake sms sender', - 'from' => 'fakesmssender', + 'from' => 'fakesmssender', ]); } @@ -39,10 +39,10 @@ public function testSuccessSend() $this->assertTrue($result); $this->assertDatabaseHas(SmsReport::class, [ - 'mobile' => $this->mobile, + 'mobile' => $this->mobile, 'success' => true, 'message' => 'Test fake sms sender', - 'from' => 'fakesmssender', + 'from' => 'fakesmssender', ]); } } diff --git a/tests/Feature/Drivers/KavenegarTest.php b/tests/Feature/Drivers/KavenegarTest.php index 4e1b2f8..29a257c 100644 --- a/tests/Feature/Drivers/KavenegarTest.php +++ b/tests/Feature/Drivers/KavenegarTest.php @@ -2,10 +2,10 @@ namespace HoomanMirghasemi\Sms\Tests\Feature\Drivers; -use Mockery\MockInterface; use HoomanMirghasemi\Sms\Drivers\Kavenegar; use HoomanMirghasemi\Sms\Message; use HoomanMirghasemi\Sms\Tests\TestCase; +use Mockery\MockInterface; class KavenegarTest extends TestCase { diff --git a/tests/Feature/SmsTest.php b/tests/Feature/SmsTest.php index 651dd1e..95d8bc2 100644 --- a/tests/Feature/SmsTest.php +++ b/tests/Feature/SmsTest.php @@ -2,12 +2,12 @@ namespace HoomanMirghasemi\Sms\Tests\Feature; -use Mockery\MockInterface; use HoomanMirghasemi\Sms\Drivers\FakeSmsSender; use HoomanMirghasemi\Sms\Drivers\Kavenegar; use HoomanMirghasemi\Sms\Models\SmsReport; use HoomanMirghasemi\Sms\SmsManager; use HoomanMirghasemi\Sms\Tests\TestCase; +use Mockery\MockInterface; class SmsTest extends TestCase { @@ -28,16 +28,16 @@ public function testSendingSmsCheckSaveLogs() ->send(); $this->assertDatabaseCount(SmsReport::class, 2); $this->assertDatabaseHas(SmsReport::class, [ - 'mobile' => $this->mobile, + 'mobile' => $this->mobile, 'success' => true, 'message' => 'Test successful send sms.', - 'from' => 'fakesmssender', + 'from' => 'fakesmssender', ]); $this->assertDatabaseHas(SmsReport::class, [ - 'mobile' => $this->mobile, + 'mobile' => $this->mobile, 'success' => false, 'message' => 'Test failed send sms.', - 'from' => 'fakesmssender', + 'from' => 'fakesmssender', ]); } diff --git a/tests/Feature/VoiceCallTest.php b/tests/Feature/VoiceCallTest.php index ace4d63..c6a974e 100644 --- a/tests/Feature/VoiceCallTest.php +++ b/tests/Feature/VoiceCallTest.php @@ -4,8 +4,8 @@ use HoomanMirghasemi\Sms\Drivers\FakeSmsSender; use HoomanMirghasemi\Sms\Models\SmsReport; -use HoomanMirghasemi\Sms\VoiceCallManager; use HoomanMirghasemi\Sms\Tests\TestCase; +use HoomanMirghasemi\Sms\VoiceCallManager; class VoiceCallTest extends TestCase { @@ -24,12 +24,12 @@ public function testSendingVoiceCallCheckSaveLogs() ->send(); $this->assertDatabaseCount(SmsReport::class, 2); $this->assertDatabaseHas(SmsReport::class, [ - 'mobile' => '+9800', + 'mobile' => '+9800', 'success' => 1, 'message' => 'Test successful send voice call.', ]); $this->assertDatabaseHas(SmsReport::class, [ - 'mobile' => '+9800', + 'mobile' => '+9800', 'success' => 0, 'message' => 'Test failed send voice call.', ]); diff --git a/tests/Feature/Web/SmsControllerTest.php b/tests/Feature/Web/SmsControllerTest.php index 0d9fa77..7bc7586 100644 --- a/tests/Feature/Web/SmsControllerTest.php +++ b/tests/Feature/Web/SmsControllerTest.php @@ -6,7 +6,6 @@ class SmsControllerTest extends TestCase { - public function testIndexSuccess() { $response = $this->get(route('sms.index')); diff --git a/tests/TestCase.php b/tests/TestCase.php index 1cb95e3..f6b0593 100644 --- a/tests/TestCase.php +++ b/tests/TestCase.php @@ -2,15 +2,16 @@ namespace HoomanMirghasemi\Sms\Tests; -use Illuminate\Foundation\Testing\RefreshDatabase; -use Orchestra\Testbench\TestCase as BaseTestCase; use HoomanMirghasemi\Sms\Providers\EventServiceProvider; use HoomanMirghasemi\Sms\Providers\RouteServiceProvider; use HoomanMirghasemi\Sms\Providers\SmsProvider; +use Illuminate\Foundation\Testing\RefreshDatabase; +use Orchestra\Testbench\TestCase as BaseTestCase; abstract class TestCase extends BaseTestCase { use RefreshDatabase; + protected function getPackageProviders($app): array { return [ @@ -28,13 +29,12 @@ protected function getEnvironmentSetUp($app): void // Setup default database to use sqlite :memory: $app['config']->set('database.default', 'testSmsDb'); $app['config']->set('database.connections.testSmsDb', [ - 'driver' => 'sqlite', - 'database' => ':memory:', - 'prefix' => '', + 'driver' => 'sqlite', + 'database' => ':memory:', + 'prefix' => '', 'foreign_key_constraints' => true, ]); $app['config']->set('sms.driver', 'fake'); } - }