Passed
Push — master ( cc6190...196023 )
by Sebastian
36s queued 10s
created

Info::getCurrentCommitHash()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 6
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 4
CRAP Score 1

Importance

Changes 0
Metric Value
eloc 3
c 0
b 0
f 0
dl 0
loc 6
ccs 4
cts 4
cp 1
rs 10
cc 1
nc 1
nop 0
crap 1
1
<?php
2
/**
3
 * This file is part of SebastianFeldmann\Git.
4
 *
5
 * (c) Sebastian Feldmann <[email protected]>
6
 *
7
 * For the full copyright and license information, please view the LICENSE
8
 * file that was distributed with this source code.
9
 */
10
namespace SebastianFeldmann\Git\Operator;
11
12
use SebastianFeldmann\Git\Command\Describe\GetCurrentTag;
13
use SebastianFeldmann\Git\Command\RevParse\GetCommitHash;
14
15
/**
16
 * Class Info
17
 *
18
 * @package SebastianFeldmann\Git
19
 * @author  Sebastian Feldmann <[email protected]>
20
 * @link    https://github.com/sebastianfeldmann/git
21
 * @since   Class available since Release 1.0.8
22
 */
23
class Info extends Base
24
{
25
    /**
26
     * Returns the tag tag of the current commit
27
     *
28
     * @return string
29
     */
30 2
    public function getCurrentTag() : string
31
    {
32 2
        $cmd    = new GetCurrentTag($this->repo->getRoot());
33 2
        $result = $this->runner->run($cmd);
34
35 1
        return trim($result->getStdOut());
36
    }
37
38
    /**
39
     * Returns the the hash of the current commit
40
     *
41
     * @return string
42
     */
43 2
    public function getCurrentCommitHash() : string
44
    {
45 2
        $cmd    = new GetCommitHash($this->repo->getRoot());
46 2
        $result = $this->runner->run($cmd);
47
48 1
        return trim($result->getStdOut());
49
    }
50
}
51