Passed
Push — master ( 33c3a2...f45f40 )
by Brian
02:22
created

InstallsInertiaVueStack::installInertiaVueStack()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 33
Code Lines 19

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 18
CRAP Score 2.0005

Importance

Changes 0
Metric Value
cc 2
eloc 19
nc 2
nop 0
dl 0
loc 33
rs 9.6333
c 0
b 0
f 0
ccs 18
cts 19
cp 0.9474
crap 2.0005
1
<?php
2
3
namespace Bmatovu\MultiAuth\Console\Traits;
4
5
use Illuminate\Filesystem\Filesystem;
6
use Illuminate\Support\Str;
7
8
trait InstallsInertiaVueStack
9
{
10
    /**
11
     * Install the InertiaVue Breeze stack.
12
     *
13
     * @return null|int
14
     */
15 1
    protected function installInertiaVueStack()
16
    {
17 1
        $fs = new Filesystem;
18 1
        $guard = $this->argument('guard');
0 ignored issues
show
Bug introduced by
It seems like argument() must be provided by classes using this trait. How about adding it as abstract method to this trait? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

18
        /** @scrutinizer ignore-call */ 
19
        $guard = $this->argument('guard');
Loading history...
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/inertia/src', app_path("Modules/{$pluralClass}"));
26
27
        // Views...
28 1
        $fs->ensureDirectoryExists(resource_path("views/{$singularSlug}"));
29 1
        $fs->copyDirectory(__DIR__ . '/../../../.stubs/vue/resources/js', resource_path("js/{$pluralClass}"));
30
31 1
        $fs->ensureDirectoryExists(resource_path("views/{$singularSlug}"));
32 1
        $fs->copyDirectory(__DIR__ . '/../../../.stubs/vue/resources/views', resource_path("views/{$singularSlug}"));
33
34
        // Tests...
35 1
        $fs->ensureDirectoryExists(base_path("tests/Feature/{$pluralClass}"));
36 1
        if ($this->option('pest')) {
0 ignored issues
show
Bug introduced by
It seems like option() must be provided by classes using this trait. How about adding it as abstract method to this trait? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

36
        if ($this->/** @scrutinizer ignore-call */ option('pest')) {
Loading history...
37
            $fs->copyDirectory(__DIR__ . '/../../../.stubs/inertia/pest-tests/Feature', base_path("tests/Feature/{$pluralClass}"));
38
        } else {
39 1
            $fs->copyDirectory(__DIR__ . '/../../../.stubs/inertia/tests/Feature', base_path("tests/Feature/{$pluralClass}"));
40
        }
41
42
        // Conclude...
43 1
        $this->info("{$singularClass} guard successfully setup.");
0 ignored issues
show
Bug introduced by
It seems like info() must be provided by classes using this trait. How about adding it as abstract method to this trait? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

43
        $this->/** @scrutinizer ignore-call */ 
44
               info("{$singularClass} guard successfully setup.");
Loading history...
44
45 1
        $serviceProvider = "App\\Modules\\{$pluralClass}\\{$singularClass}ServiceProvider::class";
46
47 1
        $this->info("\nRegister `{$serviceProvider}` in `config/app.php`");
48
    }
49
}
50