GetCommitHash::getGitCommand()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 1
CRAP Score 1

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 1
c 1
b 0
f 0
dl 0
loc 3
ccs 1
cts 1
cp 1
rs 10
cc 1
nc 1
nop 0
crap 1
1
<?php
2
3
/**
4
 * This file is part of SebastianFeldmann\Git.
5
 *
6
 * (c) Sebastian Feldmann <[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 SebastianFeldmann\Git\Command\RevParse;
13
14
use SebastianFeldmann\Git\Command\Base;
15
16
/**
17
 * Class GetCommitHash
18
 *
19
 * @package SebastianFeldmann\Git
20
 * @author  Sebastian Feldmann <[email protected]>
21
 * @link    https://github.com/sebastianfeldmann/git
22
 * @since   Class available since Release 0.9.0
23
 */
24
class GetCommitHash extends Base
25
{
26
    /**
27
     * Revision to look up.
28
     *
29
     * @var string
30
     */
31
    private $rev = 'HEAD';
32
33
    /**
34
     * Set revision to look up.
35
     *
36
     * @param  string $revision
37 1
     * @return \SebastianFeldmann\Git\Command\RevParse\GetCommitHash
38
     */
39 1
    public function revision(string $revision): GetCommitHash
40 1
    {
41
        $this->rev = $revision;
42
        return $this;
43
    }
44
45
    /**
46
     * Return the command to execute.
47
     *
48 1
     * @return string
49
     */
50 1
    protected function getGitCommand(): string
51
    {
52
        return 'rev-parse --verify ' . $this->rev;
53
    }
54
}
55