GitConfig::shell()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 1

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 4
ccs 2
cts 2
cp 1
rs 10
cc 1
eloc 2
nc 1
nop 1
crap 1
1
<?php
2
3
namespace CL\ComposerInit;
4
5
/**
6
 * @author    Ivan Kerin <[email protected]>
7
 * @copyright (c) 2014 Clippings Ltd.
8
 * @license   http://spdx.org/licenses/BSD-3-Clause
9
 */
10
class GitConfig
11
{
12
    /**
13
     * @param  string $option
14
     * @return string
15
     */
16 1
    public function get($option)
17
    {
18 1
        return $this->shell("git config $option");
19
    }
20
21
    /**
22
     * @param  string $command
23
     * @return string
24
     */
25 1
    public function shell($command)
26
    {
27 1
        return trim(shell_exec($command));
28
    }
29
30
    /**
31
     * @return string|null
32
     */
33 2
    public function getOrigin()
34
    {
35 2
        $origin = $this->get('remote.origin.url');
36
37 2
        if ($origin) {
38 2
            if (preg_match('/^.*github.com[:\/](.*).git$/', $origin, $matches)) {
39 2
                return $matches[1];
40
            }
41
        }
42 2
    }
43
}
44
45
46