Semver   A
last analyzed

Complexity

Total Complexity 6

Size/Duplication

Total Lines 41
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 6
eloc 16
dl 0
loc 41
rs 10
c 1
b 0
f 0

6 Methods

Rating   Name   Duplication   Size   Complexity  
A runSemver() 0 10 1
A minor() 0 3 1
A patch() 0 3 1
A major() 0 3 1
A for() 0 3 1
A __construct() 0 3 1
1
<?php
2
3
namespace Sfneal\Cruise\Services;
4
5
use Illuminate\Support\Facades\Process;
6
use Sfneal\Cruise\Utils\ScriptsPath;
7
8
final class Semver
9
{
10
    use ScriptsPath;
11
12
    private string $version;
13
14
    public function __construct(string $version)
15
    {
16
        $this->version = $version;
17
    }
18
19
    public static function for(string $version): Semver
20
    {
21
        return new self($version);
22
    }
23
24
    public function major(): string
25
    {
26
        return $this->runSemver('major');
27
    }
28
29
    public function minor(): string
30
    {
31
        return $this->runSemver('minor');
32
    }
33
34
    public function patch(): string
35
    {
36
        return $this->runSemver('patch');
37
    }
38
39
    private function runSemver(string $type): string
40
    {
41
        return trim(Process::path(base_path())
42
            ->run([
43
                $this->getVersionScriptPath('semver'),
44
                'bump',
45
                $type,
46
                $this->version,
47
            ])
48
            ->output());
49
    }
50
}
51