Git   A
last analyzed

Complexity

Total Complexity 11

Size/Duplication

Total Lines 73
Duplicated Lines 0 %

Coupling/Cohesion

Components 2
Dependencies 1

Test Coverage

Coverage 0%

Importance

Changes 0
Metric Value
wmc 11
lcom 2
cbo 1
dl 0
loc 73
ccs 0
cts 40
cp 0
rs 10
c 0
b 0
f 0

9 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 5 2
A hasGit() 0 5 1
A init() 0 4 1
A add() 0 4 1
A addAll() 0 4 1
A commit() 0 4 1
A setRemote() 0 4 1
A push() 0 4 1
A execute() 0 11 2
1
<?php namespace Packedge\Workbench\Tools;
2
3
use Symfony\Component\Process\ExecutableFinder;
4
5
class Git
6
{
7
    /**
8
     * @var string
9
     */
10
    protected $repositoryPath;
11
    /**
12
     * @var ExecutableFinder
13
     */
14
    private $executableFinder;
15
16
    /**
17
     * @param string $repositoryPath
18
     * @param ExecutableFinder $executableFinder
19
     */
20
    public function __construct($repositoryPath, ExecutableFinder $executableFinder)
21
    {
22
        $this->repositoryPath = realpath($repositoryPath);
23
        $this->executableFinder = $executableFinder ?: new ExecutableFinder;
24
    }
25
26
    public function hasGit()
27
    {
28
        $result = $this->executableFinder->find('git');
29
        var_dump($result);
0 ignored issues
show
Security Debugging Code introduced by
var_dump($result); looks like debug code. Are you sure you do not want to remove it? This might expose sensitive data.
Loading history...
30
    }
31
32
    public function init()
33
    {
34
        $this->execute('git init');
35
    }
36
37
    public function add(array $files)
0 ignored issues
show
Unused Code introduced by
The parameter $files is not used and could be removed.

This check looks from parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
38
    {
39
        // TODO: logic
40
    }
41
42
    public function addAll()
43
    {
44
        // TODO: logic
45
    }
46
47
    public function commit($message)
0 ignored issues
show
Unused Code introduced by
The parameter $message is not used and could be removed.

This check looks from parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
48
    {
49
        // TODO: logic
50
    }
51
52
    public function setRemote($url)
0 ignored issues
show
Unused Code introduced by
The parameter $url is not used and could be removed.

This check looks from parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
53
    {
54
        // TODO: logic
55
    }
56
57
    public function push()
58
    {
59
        // TODO: logic
60
    }
61
62
    /**
63
     * @param  string  $command
64
     * @throws RuntimeException
65
     */
66
    protected function execute($command)
67
    {
68
        $cwd = getcwd();
69
        chdir($this->repositoryPath);
70
        exec($command, $output, $returnValue);
71
        chdir($cwd);
72
        if ($returnValue !== 0) {
73
            throw new RuntimeException($output);
74
        }
75
        return $output;
76
    }
77
}