GitConfig::getOrigin()   A
last analyzed

Complexity

Conditions 3
Paths 3

Size

Total Lines 10
Code Lines 5

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 6
CRAP Score 3.0261

Importance

Changes 2
Bugs 1 Features 0
Metric Value
c 2
b 1
f 0
dl 0
loc 10
ccs 6
cts 7
cp 0.8571
rs 9.4285
cc 3
eloc 5
nc 3
nop 0
crap 3.0261
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