Passed
Push — master ( d5f13b...33c3a2 )
by Brian
02:19
created

InstallsBladeStack   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 37
Duplicated Lines 0 %

Test Coverage

Coverage 94.12%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 18
c 1
b 0
f 0
dl 0
loc 37
ccs 16
cts 17
cp 0.9412
rs 10
wmc 2

1 Method

Rating   Name   Duplication   Size   Complexity  
A installBladeStack() 0 30 2
1
<?php
2
3
namespace Bmatovu\MultiAuth\Console\Traits;
4
5
use Illuminate\Filesystem\Filesystem;
6
use Illuminate\Support\Str;
7
8
trait InstallsBladeStack
9
{
10
    /**
11
     * Install the Blade Breeze stack.
12
     *
13
     * @return null|int
14
     */
15 1
    protected function installBladeStack()
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/blade/src', app_path("Modules/{$pluralClass}"));
26
27
        // Views...
28 1
        $fs->ensureDirectoryExists(resource_path("views/{$singularSlug}"));
29 1
        $fs->copyDirectory(__DIR__ . '/../../../.stubs/blade/resources/views', resource_path("views/{$singularSlug}"));
30
31
        // Tests...
32 1
        $fs->ensureDirectoryExists(base_path("tests/Feature/{$singularClass}"));
33 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

33
        if ($this->/** @scrutinizer ignore-call */ option('pest')) {
Loading history...
34
            $fs->copyDirectory(__DIR__ . '/../../../.stubs/blade/pest-tests/Feature', base_path("tests/Feature/{$singularClass}"));
35
        } else {
36 1
            $fs->copyDirectory(__DIR__ . '/../../../.stubs/blade/tests/Feature', base_path("tests/Feature/{$singularClass}"));
37
        }
38
39
        // Conclude...
40 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

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