Passed
Push — master ( 4fc3f1...05af06 )
by Brian
02:29
created

InstallsBladeStack::installBladeStack()   A

Complexity

Conditions 3
Paths 4

Size

Total Lines 39
Code Lines 23

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 22
CRAP Score 3.0007

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 3
eloc 23
c 1
b 0
f 0
nc 4
nop 0
dl 0
loc 39
ccs 22
cts 23
cp 0.9565
crap 3.0007
rs 9.552
1
<?php
2
3
namespace Bmatovu\MultiAuth\Console\Traits;
4
5
use Illuminate\Filesystem\Filesystem;
6
use Illuminate\Support\Str;
7
use Symfony\Component\Finder\Finder;
0 ignored issues
show
Bug introduced by
The type Symfony\Component\Finder\Finder was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
8
9
trait InstallsBladeStack
10
{
11
    /**
12
     * Install the Blade Breeze stack.
13
     *
14
     * @return null|int
15
     */
16 1
    protected function installBladeStack()
17
    {
18 1
        $fs = new Filesystem;
19 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

19
        /** @scrutinizer ignore-call */ 
20
        $guard = $this->argument('guard');
Loading history...
20 1
        $pluralClass = Str::plural(Str::studly($guard));
21 1
        $singularSlug = Str::singular(Str::slug($guard));
22 1
        $singularClass = Str::singular(Str::studly($guard));
23
24 1
        if (!$this->option('dark')) {
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

24
        if (!$this->/** @scrutinizer ignore-call */ option('dark')) {
Loading history...
25 1
            $finder = (new Finder)
26 1
                ->in(__DIR__ . '/../../../.stubs/blade/resources/views')
27 1
                ->name('*.blade.php')
28 1
                ->notName('welcome.blade.php');
29
30 1
            $this->removeDarkClasses($finder);
0 ignored issues
show
Bug introduced by
It seems like removeDarkClasses() 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

30
            $this->/** @scrutinizer ignore-call */ 
31
                   removeDarkClasses($finder);
Loading history...
31
        }
32
33
        // Module...
34 1
        $fs->ensureDirectoryExists(app_path("Modules/{$pluralClass}"));
35 1
        $fs->copyDirectory(__DIR__ . '/../../../.stubs/blade/src', app_path("Modules/{$pluralClass}"));
36
37
        // Views...
38 1
        $fs->ensureDirectoryExists(resource_path("views/{$singularSlug}"));
39 1
        $fs->copyDirectory(__DIR__ . '/../../../.stubs/blade/resources/views', resource_path("views/{$singularSlug}"));
40
41
        // Tests...
42 1
        $fs->ensureDirectoryExists(base_path("tests/Feature/{$pluralClass}"));
43 1
        if ($this->option('pest')) {
44
            $fs->copyDirectory(__DIR__ . '/../../../.stubs/blade/pest-tests/Feature', base_path("tests/Feature/{$pluralClass}"));
45
        } else {
46 1
            $fs->copyDirectory(__DIR__ . '/../../../.stubs/blade/tests/Feature', base_path("tests/Feature/{$pluralClass}"));
47
        }
48
49
        // Conclude...
50 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

50
        $this->/** @scrutinizer ignore-call */ 
51
               info("{$singularClass} guard successfully setup.");
Loading history...
51
52 1
        $serviceProvider = "App\\Modules\\{$pluralClass}\\{$singularClass}ServiceProvider::class";
53
54 1
        $this->info("\nRegister `{$serviceProvider}` in `config/app.php`");
55
    }
56
}
57