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

Publish::handle()   A

Complexity

Conditions 3
Paths 2

Size

Total Lines 24

Duplication

Lines 7
Ratio 29.17 %

Importance

Changes 0
Metric Value
dl 7
loc 24
rs 9.536
c 0
b 0
f 0
cc 3
nc 2
nop 0
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