Completed
Push — stable ( 86ecc3...3a45ea )
by Nuno
07:34
created

GitVersionServiceProvider   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 19
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 3

Test Coverage

Coverage 75%

Importance

Changes 0
Metric Value
wmc 2
c 0
b 0
f 0
lcom 1
cbo 3
dl 0
loc 19
ccs 6
cts 8
cp 0.75
rs 10

1 Method

Rating   Name   Duplication   Size   Complexity  
A register() 0 11 2
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 21
    public function register(): void
28
    {
29 21
        $this->app->bind(
30 21
            'git.version',
31 21
            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 21
            }
36
        );
37 21
    }
38
}
39