NoCommitCommand::handle()   A
last analyzed

Complexity

Conditions 3
Paths 6

Size

Total Lines 15
Code Lines 9

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 9
CRAP Score 3

Importance

Changes 2
Bugs 0 Features 1
Metric Value
cc 3
eloc 9
c 2
b 0
f 1
nc 6
nop 1
dl 0
loc 15
ccs 9
cts 9
cp 1
crap 3
rs 9.9666
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Vasoft\LaravelVersionIncrement\Commands;
6
7
use Illuminate\Console\Command;
8
use Vasoft\LaravelVersionIncrement\Exceptions\ModuleException;
9
10
class NoCommitCommand extends Command
11
{
12
    protected $signature = 'vs-version:no-commit
13
                            {type? : One of: major, minor, patch, or leave empty for auto}';
14
    protected $description = 'Process without making a commit and version tag';
15
16 5
    public function handle(?CommandRunner $runner = null): int
17
    {
18 5
        $runner ??= new CommandRunner();
19 5
        $type = is_string($this->argument('type')) ? $this->argument('type') : '';
20
21
        try {
22 5
            $runner->noCommit($type);
23 4
            $this->output->write($runner->getLastOutput());
24 1
        } catch (ModuleException $e) {
25 1
            $this->error($e->getMessage());
26
27 1
            return self::FAILURE;
28
        }
29
30 4
        return self::SUCCESS;
31
    }
32
}
33