diff --git a/composer.json b/composer.json index 6ffedc35..7cf3c596 100644 --- a/composer.json +++ b/composer.json @@ -39,7 +39,8 @@ "extra": { "laravel": { "providers": [ - "Arcanedev\\LogViewer\\LogViewerServiceProvider" + "Arcanedev\\LogViewer\\LogViewerServiceProvider", + "Arcanedev\\LogViewer\\Providers\\ServicesProvider" ] } } diff --git a/src/LogViewerServiceProvider.php b/src/LogViewerServiceProvider.php index bfd30e1b..e1095fc8 100644 --- a/src/LogViewerServiceProvider.php +++ b/src/LogViewerServiceProvider.php @@ -36,10 +36,7 @@ public function register(): void $this->registerConfig(); - $this->registerProviders([ - Providers\ServicesProvider::class, - Providers\RouteServiceProvider::class, - ]); + $this->registerProvider(Providers\RouteServiceProvider::class); $this->registerCommands([ Commands\PublishCommand::class, diff --git a/src/Providers/ServicesProvider.php b/src/Providers/DeferredServicesProvider.php similarity index 79% rename from src/Providers/ServicesProvider.php rename to src/Providers/DeferredServicesProvider.php index b804b249..2ab0178b 100644 --- a/src/Providers/ServicesProvider.php +++ b/src/Providers/DeferredServicesProvider.php @@ -3,15 +3,14 @@ use Arcanedev\LogViewer\{Contracts, LogViewer, Utilities}; use Arcanedev\Support\Providers\ServiceProvider; use Illuminate\Contracts\Support\DeferrableProvider; -use Illuminate\Support\Arr; /** - * Class ServicesProvider + * Class DeferredServicesProvider * * @package Arcanedev\LogViewer\Providers * @author ARCANEDEV */ -class ServicesProvider extends ServiceProvider implements DeferrableProvider +class DeferredServicesProvider extends ServiceProvider implements DeferrableProvider { /* ----------------------------------------------------------------- | Main Methods @@ -69,14 +68,10 @@ private function registerLogViewer(): void private function registerLogLevels(): void { $this->singleton(Contracts\Utilities\LogLevels::class, function ($app) { - /** - * @var \Illuminate\Config\Repository $config - * @var \Illuminate\Translation\Translator $translator - */ - $config = $app['config']; - $translator = $app['translator']; - - return new Utilities\LogLevels($translator, $config->get('log-viewer.locale')); + return new Utilities\LogLevels( + $app['translator'], + $app['config']->get('log-viewer.locale') + ); }); } @@ -104,13 +99,12 @@ private function registerFilesystem(): void $this->singleton(Contracts\Utilities\Filesystem::class, function ($app) { /** @var \Illuminate\Config\Repository $config */ $config = $app['config']; - $pattern = $config->get('log-viewer.pattern', []); $filesystem = new Utilities\Filesystem($app['files'], $config->get('log-viewer.storage-path')); return $filesystem->setPattern( - Arr::get($pattern, 'prefix', Utilities\Filesystem::PATTERN_PREFIX), - Arr::get($pattern, 'date', Utilities\Filesystem::PATTERN_DATE), - Arr::get($pattern, 'extension', Utilities\Filesystem::PATTERN_EXTENSION) + $config->get('log-viewer.pattern.prefix', Utilities\Filesystem::PATTERN_PREFIX), + $config->get('log-viewer.pattern.date', Utilities\Filesystem::PATTERN_DATE), + $config->get('log-viewer.pattern.extension', Utilities\Filesystem::PATTERN_EXTENSION) ); }); } diff --git a/tests/Providers/UtilitiesServiceProviderTest.php b/tests/Providers/DeferredServicesProviderTest.php similarity index 84% rename from tests/Providers/UtilitiesServiceProviderTest.php rename to tests/Providers/DeferredServicesProviderTest.php index a30b4367..523d8001 100644 --- a/tests/Providers/UtilitiesServiceProviderTest.php +++ b/tests/Providers/DeferredServicesProviderTest.php @@ -1,23 +1,23 @@ */ -class UtilitiesServiceProviderTest extends TestCase +class DeferredServicesProviderTest extends TestCase { /* ----------------------------------------------------------------- | Properties | ----------------------------------------------------------------- */ - /** @var \Arcanedev\LogViewer\Providers\ServicesProvider */ + /** @var \Arcanedev\LogViewer\Providers\DeferredServicesProvider */ private $provider; /* ----------------------------------------------------------------- @@ -29,7 +29,7 @@ protected function setUp(): void { parent::setUp(); - $this->provider = $this->app->getProvider(ServicesProvider::class); + $this->provider = $this->app->getProvider(DeferredServicesProvider::class); } protected function tearDown(): void @@ -52,7 +52,7 @@ public function it_can_be_instantiated() \Illuminate\Support\ServiceProvider::class, \Illuminate\Contracts\Support\DeferrableProvider::class, \Arcanedev\Support\Providers\ServiceProvider::class, - ServicesProvider::class, + DeferredServicesProvider::class, ]; foreach ($expectations as $expected) { diff --git a/tests/TestCase.php b/tests/TestCase.php index c9c30ce1..3a06a5f0 100644 --- a/tests/TestCase.php +++ b/tests/TestCase.php @@ -61,6 +61,7 @@ protected function getPackageProviders($app) { return [ \Arcanedev\LogViewer\LogViewerServiceProvider::class, + \Arcanedev\LogViewer\Providers\DeferredServicesProvider::class, ]; }