| Conditions | 2 |
| Paths | 2 |
| Total Lines | 25 |
| Code Lines | 15 |
| Lines | 0 |
| Ratio | 0 % |
| Tests | 14 |
| CRAP Score | 2.0011 |
| Changes | 0 | ||
| 1 | <?php |
||
| 15 | 1 | protected function installApiStack() |
|
| 16 | { |
||
| 17 | 1 | $fs = new Filesystem; |
|
| 18 | 1 | $guard = $this->argument('guard'); |
|
|
|
|||
| 19 | 1 | $pluralClass = Str::plural(Str::studly($guard)); |
|
| 20 | 1 | $singularSlug = Str::singular(Str::slug($guard)); |
|
| 21 | 1 | $singularClass = Str::singular(Str::studly($guard)); |
|
| 22 | |||
| 23 | // Module... |
||
| 24 | 1 | $fs->ensureDirectoryExists(app_path("Modules/{$pluralClass}")); |
|
| 25 | 1 | $fs->copyDirectory(__DIR__ . '/../../../.stubs/api/src', app_path("Modules/{$pluralClass}")); |
|
| 26 | |||
| 27 | // Tests... |
||
| 28 | 1 | $fs->ensureDirectoryExists(base_path("tests/Feature/{$singularClass}")); |
|
| 29 | 1 | if ($this->option('pest')) { |
|
| 30 | $fs->copyDirectory(__DIR__ . '/../../../.stubs/api/pest-tests/Feature', base_path("tests/Feature/{$singularClass}")); |
||
| 31 | } else { |
||
| 32 | 1 | $fs->copyDirectory(__DIR__ . '/../../../.stubs/api/tests/Feature', base_path("tests/Feature/{$singularClass}")); |
|
| 33 | } |
||
| 34 | // Conclude... |
||
| 35 | 1 | $this->info("{$singularClass} guard successfully setup."); |
|
| 36 | |||
| 37 | 1 | $serviceProvider = "App\\Modules\\{$pluralClass}\\{$singularClass}ServiceProvider::class"; |
|
| 38 | |||
| 39 | 1 | $this->info("\nRegister `{$serviceProvider}` in `config/app.php`"); |
|
| 40 | } |
||
| 42 |