CheckExtractBladeIncludes   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 31
Duplicated Lines 100 %

Coupling/Cohesion

Components 1
Dependencies 5

Importance

Changes 0
Metric Value
dl 31
loc 31
rs 10
c 0
b 0
f 0
wmc 3
lcom 1
cbo 5

2 Methods

Rating   Name   Duplication   Size   Complexity  
A handle() 14 14 2
A startWarning() 7 7 1

How to fix   Duplicated Code   

Duplicated Code

Duplicate code is one of the most pungent code smells. A rule that is often used is to re-structure code once it is duplicated in three or more places.

Common duplication problems, and corresponding solutions are:

1
<?php
2
3
namespace Imanghafoori\LaravelMicroscope\Commands;
4
5
use Illuminate\Console\Command;
6
use Imanghafoori\LaravelMicroscope\BladeFiles;
7
use Imanghafoori\LaravelMicroscope\Checks\ExtractBladePartial;
8
use Imanghafoori\LaravelMicroscope\ErrorReporters\ErrorPrinter;
9
use Imanghafoori\LaravelMicroscope\Traits\LogsErrors;
10
11 View Code Duplication
class CheckExtractBladeIncludes extends Command
0 ignored issues
show
Duplication introduced by
This class seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
12
{
13
    use LogsErrors;
14
15
    protected $signature = 'check:extract_blades';
16
17
    protected $description = 'Checks to extract blade partials';
18
19
    public function handle(ErrorPrinter $errorPrinter)
20
    {
21
        if (! $this->startWarning()) {
22
            return;
23
        }
24
25
        event('microscope.start.command');
26
27
        $errorPrinter->printer = $this->output;
28
29
        BladeFiles::check([ExtractBladePartial::class]);
30
31
        $this->info('Blade files extracted.');
32
    }
33
34
    private function startWarning()
35
    {
36
        $this->info('Checking to extract blade partials...');
37
        $this->warn('This command is going to make changes to your files!');
38
39
        return $this->output->confirm('Do you have committed everything in git?', true);
40
    }
41
}
42