IncrementCommand::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 1
Bugs 0 Features 1
Metric Value
cc 3
eloc 9
c 1
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 IncrementCommand extends Command
11
{
12
    protected $signature = 'vs-version:increment
13
                            {type? : One of: major, minor, patch, or leave empty for auto}';
14
15
    protected $description = 'Increment project version using voral/vs-version-increment';
16
17 5
    public function handle(?CommandRunner $runner = null): int
18
    {
19 5
        $runner ??= new CommandRunner();
20 5
        $type = is_string($this->argument('type')) ? $this->argument('type') : '';
21
22
        try {
23 5
            $runner->increment($type);
24 4
            $this->output->write($runner->getLastOutput());
25 1
        } catch (ModuleException $e) {
26 1
            $this->error($e->getMessage());
27
28 1
            return self::FAILURE;
29
        }
30
31 4
        return self::SUCCESS;
32
    }
33
}
34