diff --git a/src/Commands/MultiAuthInstallCommand.php b/src/Commands/MultiAuthInstallCommand.php index 4dde5c3..1cbaf60 100644 --- a/src/Commands/MultiAuthInstallCommand.php +++ b/src/Commands/MultiAuthInstallCommand.php @@ -7,6 +7,7 @@ use Hesto\MultiAuth\Commands\Traits\OverridesGetArguments; use Hesto\MultiAuth\Commands\Traits\ParsesServiceInput; use Illuminate\Support\Facades\Artisan; +use Illuminate\Support\Str; use SplFileInfo; use Symfony\Component\Console\Input\InputOption; @@ -36,7 +37,7 @@ class MultiAuthInstallCommand extends InstallAndReplaceCommand */ public function fire() { - if ($this->option('lucid') && ! $this->getParsedServiceInput()) { + if ($this->option('lucid') && !$this->getParsedServiceInput()) { $this->error('You must pass a Service name with the `--lucid` option.'); return true; @@ -65,7 +66,7 @@ public function fire() '--force' => true ]); - if(!$this->option('model')) { + if (!$this->option('model')) { Artisan::call('multi-auth:model', [ 'name' => $name, '--lucid' => $lucid, @@ -76,7 +77,7 @@ public function fire() $this->installPasswordResetMigration(); } - if(!$this->option('views')) { + if (!$this->option('views')) { Artisan::call('multi-auth:views', [ 'name' => $name, 'service' => $service, @@ -85,7 +86,7 @@ public function fire() ]); } - if(!$this->option('routes')) { + if (!$this->option('routes')) { $this->installWebRoutes(); } @@ -111,21 +112,21 @@ public function installWebRoutes() $service = $this->getParsedServiceInput(); if ($lucid) { - $stub = ! $domain + $stub = !$domain ? __DIR__ . '/../stubs/Lucid/routes/web.stub' : __DIR__ . '/../stubs/Lucid/domain-routes/web.stub'; $lucidPath = base_path() . '/src/Services/' . studly_case($service) . '/Http/routes.php'; - $lucidStub = ! $domain + $lucidStub = !$domain ? __DIR__ . '/../stubs/Lucid/routes/map-method.stub' : __DIR__ . '/../stubs/Lucid/domain-routes/map-method.stub'; - if ( ! $this->contentExists($lucidPath, $lucidStub)) { + if (!$this->contentExists($lucidPath, $lucidStub)) { $lucidFile = new SplFileInfo($lucidStub); $this->appendFile($lucidPath, $lucidFile); } - if( ! $this->contentExists($lucidPath, $stub)) { + if (!$this->contentExists($lucidPath, $stub)) { $file = new SplFileInfo($stub); $this->appendFile($lucidPath, $file); @@ -141,7 +142,7 @@ public function installWebRoutes() $stub = __DIR__ . '/../stubs/domain-routes/web.stub'; } - if( ! $this->contentExists($path, $stub)) { + if (!$this->contentExists($path, $stub)) { $file = new SplFileInfo($stub); $this->appendFile($path, $file); @@ -149,7 +150,6 @@ public function installWebRoutes() } return false; - } /** @@ -162,13 +162,13 @@ public function installMigration() $name = $this->getParsedNameInput(); $migrationDir = base_path() . '/database/migrations/'; - $migrationName = 'create_' . str_plural(snake_case($name)) .'_table.php'; + $migrationName = 'create_' . Str::plural(Str::snake($name)) . '_table.php'; $migrationStub = new SplFileInfo(__DIR__ . '/../stubs/Model/migration.stub'); $files = $this->files->allFiles($migrationDir); foreach ($files as $file) { - if(str_contains($file->getFilename(), $migrationName)) { + if (Str::contains($file->getFilename(), $migrationName)) { $this->putFile($file->getPathname(), $migrationStub); return true; @@ -191,13 +191,13 @@ public function installPasswordResetMigration() $name = $this->getParsedNameInput(); $migrationDir = base_path() . '/database/migrations/'; - $migrationName = 'create_' . str_singular(snake_case($name)) .'_password_resets_table.php'; + $migrationName = 'create_' . Str::singular(Str::snake($name)) . '_password_resets_table.php'; $migrationStub = new SplFileInfo(__DIR__ . '/../stubs/Model/PasswordResetMigration.stub'); $files = $this->files->allFiles($migrationDir); foreach ($files as $file) { - if(str_contains($file->getFilename(), $migrationName)) { + if (Str::contains($file->getFilename(), $migrationName)) { $this->putFile($file->getPathname(), $migrationStub); return true; @@ -226,4 +226,4 @@ public function getOptions() ['routes', null, InputOption::VALUE_NONE, 'Exclude routes'], ]; } -} +} \ No newline at end of file diff --git a/src/Commands/Traits/OverridesCanReplaceKeywords.php b/src/Commands/Traits/OverridesCanReplaceKeywords.php index 0821216..d887048 100644 --- a/src/Commands/Traits/OverridesCanReplaceKeywords.php +++ b/src/Commands/Traits/OverridesCanReplaceKeywords.php @@ -2,6 +2,8 @@ namespace Hesto\MultiAuth\Commands\Traits; +use Illuminate\Support\Str; + trait OverridesCanReplaceKeywords { /** @@ -11,7 +13,7 @@ trait OverridesCanReplaceKeywords */ protected function getParsedNameInput() { - return mb_strtolower(str_singular($this->getNameInput())); + return mb_strtolower(Str::singular($this->getNameInput())); } /** @@ -35,7 +37,7 @@ public function replaceNames($template) $name = $this->getParsedNameInput(); $service = $this->getParsedServiceInput(); - $name = str_plural($name); + $name = Str::plural($name); $plural = [ '{{pluralCamel}}', @@ -57,30 +59,30 @@ public function replaceNames($template) ]; $replacePlural = [ - camel_case($name), - str_slug($name), - snake_case($name), - ucfirst(camel_case($name)), + Str::camel($name), + Str::slug($name), + Str::snake($name), + ucfirst(Str::camel($name)), ]; $replaceSingular = [ - str_singular(camel_case($name)), - str_singular(str_slug($name)), - str_singular(snake_case($name)), - str_singular(ucfirst(camel_case($name))), - - camel_case($service), - str_slug($service), - snake_case($service), - ucfirst(camel_case($service)), + Str::singular(Str::camel($name)), + Str::singular(Str::slug($name)), + Str::singular(Str::snake($name)), + Str::singular(ucfirst(Str::camel($name))), + + Str::camel($service), + Str::slug($service), + Str::snake($service), + ucfirst(Str::camel($service)), ]; $template = str_replace($plural, $replacePlural, $template); $template = str_replace($singular, $replaceSingular, $template); - $template = str_replace('{{Class}}', ucfirst(camel_case($name)), $template); + $template = str_replace('{{Class}}', ucfirst(Str::camel($name)), $template); return $template; } -} +} \ No newline at end of file diff --git a/src/Commands/Traits/ParsesServiceInput.php b/src/Commands/Traits/ParsesServiceInput.php index 50b7b8d..988cf11 100644 --- a/src/Commands/Traits/ParsesServiceInput.php +++ b/src/Commands/Traits/ParsesServiceInput.php @@ -2,6 +2,8 @@ namespace Hesto\MultiAuth\Commands\Traits; +use Illuminate\Support\Str; + trait ParsesServiceInput { /** @@ -11,7 +13,7 @@ trait ParsesServiceInput */ protected function getParsedServiceInput() { - return mb_strtolower(str_singular($this->getServiceInput())); + return mb_strtolower(Str::singular($this->getServiceInput())); } /**