diff --git a/config/arabic-numbers-middleware.php b/config/arabic-numbers-middleware.php index 10851b9..9caea26 100644 --- a/config/arabic-numbers-middleware.php +++ b/config/arabic-numbers-middleware.php @@ -22,7 +22,7 @@ | Supported Middleware: "arabic-to-eastern", "eastern-to-arabic" */ 'auto_middleware' => [ - Yemenifree\LaravelArabicNumbersMiddleware\Middleware\TransformEasternToArabicNumbers::class + Yemenifree\LaravelArabicNumbersMiddleware\Middleware\TransformEasternToArabicNumbers::class, ], /* @@ -59,5 +59,5 @@ */ 'except_from_arabic_to_eastern' => [ // 'mobile' - ] -]; \ No newline at end of file + ], +]; diff --git a/src/Middleware/BaseNumbersMiddleware.php b/src/Middleware/BaseNumbersMiddleware.php index c77f553..3d7f4ef 100644 --- a/src/Middleware/BaseNumbersMiddleware.php +++ b/src/Middleware/BaseNumbersMiddleware.php @@ -30,7 +30,7 @@ public function __construct(Repository $config) } /** - * get except fields + * get except fields. * * @return array */ @@ -40,7 +40,7 @@ public function getExcept() } /** - * get options from config + * get options from config. * @param string $key * @param null $default * @return array @@ -51,9 +51,9 @@ protected function getOption($key, $default = null) } /** - * check if transform from (arabic|english) to eastern + * check if transform from (arabic|english) to eastern. * - * @return boolean + * @return bool */ public function isFromArabic() { @@ -77,7 +77,7 @@ protected function transform($key, $value) } /** - * transform eastern/(arabic|english) numbers to (arabic|english)/eastern numbers inside string + * transform eastern/(arabic|english) numbers to (arabic|english)/eastern numbers inside string. * * @param string $value * @return string @@ -88,7 +88,7 @@ protected function transformNumber($value) } /** - * get array numbers to transforms + * get array numbers to transforms. * * @return string */ @@ -98,9 +98,9 @@ protected function getNumbers() } /** - * check if transform from (arabic|english) to eastern + * check if transform from (arabic|english) to eastern. * - * @return boolean + * @return bool */ public function isFromEastern() { @@ -108,7 +108,7 @@ public function isFromEastern() } /** - * Get eastern numbers array + * Get eastern numbers array. * * @return array */ diff --git a/src/Middleware/TransformArabicToEasternNumbers.php b/src/Middleware/TransformArabicToEasternNumbers.php index 1b3a7a7..25db7d1 100644 --- a/src/Middleware/TransformArabicToEasternNumbers.php +++ b/src/Middleware/TransformArabicToEasternNumbers.php @@ -7,7 +7,7 @@ class TransformArabicToEasternNumbers extends BaseNumbersMiddleware protected $from = 'arabic'; /** - * {@inheritDoc} + * {@inheritdoc} */ public function getExcept() { diff --git a/src/Middleware/TransformEasternToArabicNumbers.php b/src/Middleware/TransformEasternToArabicNumbers.php index 8591bf3..b74d05b 100644 --- a/src/Middleware/TransformEasternToArabicNumbers.php +++ b/src/Middleware/TransformEasternToArabicNumbers.php @@ -7,7 +7,7 @@ class TransformEasternToArabicNumbers extends BaseNumbersMiddleware protected $from = 'eastern'; /** - * {@inheritDoc} + * {@inheritdoc} */ public function getExcept() { diff --git a/src/ServiceProvider.php b/src/ServiceProvider.php index 6956e7e..7340fe0 100644 --- a/src/ServiceProvider.php +++ b/src/ServiceProvider.php @@ -16,11 +16,11 @@ class ServiceProvider extends BaseServiceProvider */ protected $middleware = [ 'arabic-to-eastern' => TransformArabicToEasternNumbers::class, - 'eastern-to-arabic' => TransformEasternToArabicNumbers::class + 'eastern-to-arabic' => TransformEasternToArabicNumbers::class, ]; /** - * list of group middleware to auto append middleware to them + * list of group middleware to auto append middleware to them. * * true => all groups * false => none @@ -31,13 +31,12 @@ class ServiceProvider extends BaseServiceProvider protected $groupMiddleware = false; /** - * auto append middleware + * auto append middleware. * * @var Collection */ protected $auto_middleware; - /** * Perform post-registration booting of services. * @@ -46,14 +45,14 @@ class ServiceProvider extends BaseServiceProvider public function boot() { $this->publishes([ - __DIR__ . '/../config/arabic-numbers-middleware.php' => config_path('arabic-numbers-middleware.php'), + __DIR__.'/../config/arabic-numbers-middleware.php' => config_path('arabic-numbers-middleware.php'), ], 'config'); $this->autoAppendMiddleware(); } /** - * auto append middleware to router + * auto append middleware to router. * * @return Collection|bool */ @@ -61,14 +60,16 @@ protected function autoAppendMiddleware() { $this->groupMiddleware = $this->app['config']->get('arabic-numbers-middleware.auto_register_middleware', false); - if ($this->groupMiddleware === false) + if ($this->groupMiddleware === false) { return false; + } $this->auto_middleware = collect($this->app['config']->get('arabic-numbers-middleware.auto_middleware', [])); // Register as global Middleware if ($this->groupMiddleware === true) { $kernel = $this->app->make('Illuminate\Contracts\Http\Kernel'); + return $this->auto_middleware->each(function ($middleware) use ($kernel) { $kernel->pushMiddleware($middleware); }); @@ -93,12 +94,12 @@ protected function autoAppendMiddleware() */ public function register() { - $this->mergeConfigFrom(__DIR__ . '/../config/arabic-numbers-middleware.php', 'arabic-numbers-middleware'); + $this->mergeConfigFrom(__DIR__.'/../config/arabic-numbers-middleware.php', 'arabic-numbers-middleware'); $this->registerAliasMiddleware(); } /** - * register alias middleware + * register alias middleware. */ protected function registerAliasMiddleware() { @@ -106,4 +107,4 @@ protected function registerAliasMiddleware() $this->app['router']->aliasMiddleware($alias, $middleware); } } -} \ No newline at end of file +} diff --git a/tests/ArabicMiddlewareTest.php b/tests/ArabicMiddlewareTest.php index cc19855..1d0f4bb 100644 --- a/tests/ArabicMiddlewareTest.php +++ b/tests/ArabicMiddlewareTest.php @@ -2,7 +2,6 @@ namespace Yemenifree\LaravelArabicNumbersMiddleware\Test; - use Yemenifree\LaravelArabicNumbersMiddleware\Middleware\TransformArabicToEasternNumbers; class ArabicMiddlewareTest extends TestCase @@ -54,5 +53,4 @@ protected function getEnvironmentSetUp($app) parent::getEnvironmentSetUp($app); $app['config']->set('arabic-numbers-middleware.auto_middleware', TransformArabicToEasternNumbers::class); } - -} \ No newline at end of file +} diff --git a/tests/EasternMiddlewareTest.php b/tests/EasternMiddlewareTest.php index 8f87160..f3b0c15 100644 --- a/tests/EasternMiddlewareTest.php +++ b/tests/EasternMiddlewareTest.php @@ -2,10 +2,8 @@ namespace Yemenifree\LaravelArabicNumbersMiddleware\Test; - class EasternMiddlewareTest extends TestCase { - /** @test */ public function it_will_transform_numbers_to_arabic_with_auto_append_middleware() { @@ -47,4 +45,4 @@ public function it_will_not_transform_numbers_to_arabic_without_auto_append_midd $this->refreshApp(); $this->post('login-eastern-to-arabic-auto-append', $this->easternTestData)->assertExactJson($this->easternTestData); } -} \ No newline at end of file +} diff --git a/tests/TestCase.php b/tests/TestCase.php index 5b23ffa..0aca103 100644 --- a/tests/TestCase.php +++ b/tests/TestCase.php @@ -2,8 +2,8 @@ namespace Yemenifree\LaravelArabicNumbersMiddleware\Test; -use Illuminate\Foundation\Application; use Illuminate\Http\Request; +use Illuminate\Foundation\Application; use Illuminate\Routing\RouteCollection; use Orchestra\Testbench\TestCase as Orchestra; use Yemenifree\LaravelArabicNumbersMiddleware\ServiceProvider; @@ -31,7 +31,7 @@ protected function getPackageProviders($app) } /** - * {@inheritDoc} + * {@inheritdoc} */ protected function getEnvironmentSetUp($app) { @@ -39,7 +39,7 @@ protected function getEnvironmentSetUp($app) } /** - * refresh (reboot) app + * refresh (reboot) app. * * because auto register middleware as global happen when boot app so if we need disabled it we need reboot app also */ @@ -80,4 +80,4 @@ protected function responseRequest() return response()->json($request, 200, [], JSON_UNESCAPED_UNICODE); }; } -} \ No newline at end of file +}