Semver::major()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 1
dl 0
loc 3
rs 10
c 1
b 0
f 0
cc 1
nc 1
nop 0
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