GitConfig   A
last analyzed

Complexity

Total Complexity 5

Size/Duplication

Total Lines 34
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 0

Test Coverage

Coverage 90.91%

Importance

Changes 2
Bugs 1 Features 0
Metric Value
wmc 5
c 2
b 1
f 0
lcom 0
cbo 0
dl 0
loc 34
ccs 10
cts 11
cp 0.9091
rs 10

3 Methods

Rating   Name   Duplication   Size   Complexity  
A get() 0 4 1
A shell() 0 4 1
A getOrigin() 0 10 3
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