GitHub Access Token became invalid

It seems like the GitHub access token used for retrieving details about this repository from GitHub became invalid. This might prevent certain types of inspections from being run (in particular, everything related to pull requests).
Please ask an admin of your repository to re-new the access token on this website.

Exec::setShort()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 6
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 6
rs 9.4285
c 0
b 0
f 0
cc 1
eloc 3
nc 1
nop 1
1
<?php
2
/**
3
 * Exec.php
4
 *
5
 * @package         ProjectVersioner
6
 * @subpackage      Reader
7
 */
8
9
namespace Naneau\ProjectVersioner\Reader\Git\Commit;
10
11
use Naneau\ProjectVersioner\Reader\Git\Exec as GitExec;
12
13
/**
14
 * Exec
15
 *
16
 * Reads the latest commit (short) hash from a git repository
17
 *
18
 * Example: gd504031
19
 *
20
 * @category        Naneau
21
 * @package         ProjectVersioner
22
 * @subpackage      Reader
23
 */
24
class Exec extends GitExec
25
{
26
    /**
27
     * Use short hash?
28
     *
29
     * @var bool
30
     **/
31
    private $short = true;
32
33
    /**
34
     * Constructor
35
     *
36
     * @param  bool $short
37
     * @return void
0 ignored issues
show
Comprehensibility Best Practice introduced by
Adding a @return annotation to constructors is generally not recommended as a constructor does not have a meaningful return value.

Adding a @return annotation to a constructor is not recommended, since a constructor does not have a meaningful return value.

Please refer to the PHP core documentation on constructors.

Loading history...
38
     **/
39
    public function __construct($short = true)
40
    {
41
        $this->setShort($short);
42
    }
43
44
    /**
45
     * Get use short commit hash?
46
     *
47
     * @return bool
48
     */
49
    public function getShort()
50
    {
51
        return $this->short;
52
    }
53
54
    /**
55
     * Set use short commit hash?
56
     *
57
     * @param  bool $short
58
     * @return Exec
59
     */
60
    public function setShort($short)
61
    {
62
        $this->short = $short;
63
64
        return $this;
65
    }
66
67
    /**
68
     * Get command for directory
69
     *
70
     * @param  string $directory
71
     * @return string
72
     **/
73
    protected function getCommandForDirectory($directory)
74
    {
75
        if ($this->getShort()) {
76
            return sprintf(
77
                'cd %s && git rev-parse --short HEAD',
78
                escapeshellarg($directory)
79
            );
80
        } else {
81
            return sprintf(
82
                'cd %s && git rev-parse HEAD',
83
                escapeshellarg($directory)
84
            );
85
        }
86
    }
87
}
88