Completed
Push — master ( 91746d...c63af8 )
by ReliQ
09:16
created

Update   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 45
Duplicated Lines 15.56 %

Coupling/Cohesion

Components 0
Dependencies 1

Importance

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

1 Method

Rating   Name   Duplication   Size   Complexity  
A handle() 7 22 3

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
declare(strict_types=1);
4
5
namespace ReliqArts\Docweaver\Console\Command;
6
7
use Carbon\Carbon;
8
use Illuminate\Console\Command;
9
use ReliqArts\Docweaver\Contract\Documentation\Publisher;
10
11
class Update extends SingleProductCommand
12
{
13
    /**
14
     * The name and signature of the console command.
15
     *
16
     * @var string
17
     */
18
    protected $signature = 'docweaver:update
19
                            {product? : Product name}
20
                            {--y|y : Whether to skip confirmation}
21
                            ';
22
23
    /**
24
     * The console command description.
25
     *
26
     * @var string
27
     */
28
    protected $description = 'Update documentation for product';
29
30
    /**
31
     * Execute the console command.
32
     */
33
    public function handle(): void
34
    {
35
        $productName = $this->argument('product');
36
        $skipConfirmation = $this->option('y');
37
        $confirmationMessage = sprintf(
38
            "This command will attempt to update documentation for product (%s). \n"
39
            . 'Please ensure your internet connection is stable. Ready?',
40
            $productName
41
        );
42
43
        $this->comment(PHP_EOL
44
            . "<info>♣♣♣</info> Docweaver DocumentationPublisher \n"
45
            . 'Help is here, try: php artisan docweaver:update --help');
46
47 View Code Duplication
        if ($skipConfirmation || $this->confirm($confirmationMessage)) {
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated across 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...
48
            $this->info("Updating {$productName}.\nT: " . Carbon::now()->toCookieString() . "\n----------");
49
50
            $result = $this->publisher->update($productName, $this);
51
52
            $this->displayResult($result);
53
        }
54
    }
55
}
56