Completed
Push — stable ( 386c57...2cb6a4 )
by Nuno
02:05
created

GitVersionServiceProvider::register()   A

Complexity

Conditions 2
Paths 1

Size

Total Lines 11
Code Lines 6

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 6
CRAP Score 2.0625

Importance

Changes 0
Metric Value
c 0
b 0
f 0
dl 0
loc 11
ccs 6
cts 8
cp 0.75
rs 9.4285
cc 2
eloc 6
nc 1
nop 0
crap 2.0625
1
<?php
2
3
/**
4
 * This file is part of Laravel Zero.
5
 *
6
 * (c) Nuno Maduro <[email protected]>
7
 *
8
 *  For the full copyright and license information, please view the LICENSE
9
 *  file that was distributed with this source code.
10
 */
11
12
namespace LaravelZero\Framework\Providers\GitVersion;
13
14
use Symfony\Component\Process\Process;
15
use Illuminate\Support\ServiceProvider;
16
17
/**
18
 * This is the Laravel Zero Framework Git Version Provider implementation.
19
 */
20
class GitVersionServiceProvider extends ServiceProvider
21
{
22
    /**
23
     * Register Git Tag service.
24
     *
25
     * @return void
26
     */
27 19
    public function register(): void
28
    {
29 19
        $this->app->bind(
30 19
            'git.version',
31 19
            function ($app) {
32
                ($process = new Process('git describe --tags $(git rev-list --tags --max-count=1)', $app->basePath()))->run();
33
34
                return trim($process->getOutput()) ?: 'unreleased';
35 19
            }
36
        );
37 19
    }
38
}
39