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

Publish   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 50
Duplicated Lines 14 %

Coupling/Cohesion

Components 0
Dependencies 1

Importance

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

1 Method

Rating   Name   Duplication   Size   Complexity  
A handle() 7 24 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 ReliqArts\Docweaver\Exception\InvalidDirectory;
9
10
class Publish extends SingleProductCommand
11
{
12
    /**
13
     * The name and signature of the console command.
14
     *
15
     * @var string
16
     */
17
    protected $signature = 'docweaver:publish
18
                            {product? : Product name}
19
                            {source? : Product repository}
20
                            {--y|y : Whether to skip confirmation}
21
                            ';
22
23
    /**
24
     * The console command description.
25
     *
26
     * @var string
27
     */
28
    protected $description = 'Publish documentation for product';
29
30
    /**
31
     * Execute the console command.
32
     *
33
     * @throws InvalidDirectory
34
     */
35
    public function handle(): void
36
    {
37
        $productName = $this->argument('product');
38
        $productSource = $this->argument('source');
39
        $skipConfirmation = $this->option('y');
40
        $confirmationMessage = sprintf(
41
            "This command will attempt to pull documentation for product (%s) from %s}. \n"
42
            . 'Please ensure your internet connection is stable. Ready?',
43
            $productName,
44
            $productSource
45
        );
46
47
        $this->comment(PHP_EOL
48
            . "<info>♣♣♣</info> Docweaver DocumentationPublisher \n"
49
            . 'Help is here, try: php artisan docweaver:publish --help');
50
51 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...
52
            $this->info("Publishing {$productName}.\nT: " . Carbon::now()->toCookieString() . '----------');
53
54
            $result = $this->publisher->publish($productName, $productSource, $this);
55
56
            $this->displayResult($result);
57
        }
58
    }
59
}
60