Completed
Pull Request — develop (#100)
by
unknown
03:44
created

GitBinary   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 44
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 0

Test Coverage

Coverage 100%
Metric Value
wmc 4
lcom 0
cbo 0
dl 0
loc 44
ccs 11
cts 11
cp 1
rs 10

3 Methods

Rating   Name   Duplication   Size   Complexity  
A getPath() 0 4 1
A setPath() 0 4 1
A __construct() 0 8 2
1
<?php
2
/**
3
 * GitElephant - An abstraction layer for git written in PHP
4
 * Copyright (C) 2013  Matteo Giachino
5
 *
6
 * This program is free software: you can redistribute it and/or modify
7
 * it under the terms of the GNU General Public License as published by
8
 * the Free Software Foundation, either version 3 of the License, or
9
 * (at your option) any later version.
10
 *
11
 * This program is distributed in the hope that it will be useful,
12
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14
 * GNU General Public License for more details.
15
 *
16
 * You should have received a copy of the GNU General Public License
17
 * along with this program.  If not, see [http://www.gnu.org/licenses/].
18
 */
19
20
namespace GitElephant;
21
22
/**
23
 * Git binary
24
 * It contains the reference to the system git binary
25
 *
26
 * @author Matteo Giachino <[email protected]>
27
 */
28
class GitBinary
29
{
30
    /**
31
     * the path to the repository
32
     *
33
     * @var string $path
34
     */
35
    private $path;
36
37
    /**
38
     * Class constructor
39
     *
40
     * @param null $path the physical path to the git binary
41
     */
42 103
    public function __construct($path = null)
43
    {
44 103
        if (is_null($path)) {
45
            // unix only!
46 102
            $path = exec('which git');
47 102
        }
48 103
        $this->setPath($path);
49 103
    }
50
51
    /**
52
     * path getter
53
     * returns the path of the binary
54
     *
55
     * @return mixed
56
     */
57 99
    public function getPath()
58
    {
59 99
        return $this->path;
60
    }
61
62
    /**
63
     * path setter
64
     *
65
     * @param string $path the path to the system git binary
66
     */
67 103
    public function setPath($path)
68
    {
69 103
        $this->path = $path;
70 103
    }
71
}
72