Git::getUserEmail()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 1
Bugs 0 Features 1
Metric Value
cc 1
eloc 1
c 1
b 0
f 1
nc 1
nop 0
dl 0
loc 3
ccs 0
cts 3
cp 0
crap 2
rs 10
1
<?php
2
/**
3
 * Automation tool mixed with code generator for easier continuous development
4
 *
5
 * @link      https://github.com/hiqdev/hidev
6
 * @package   hidev
7
 * @license   BSD-3-Clause
8
 * @copyright Copyright (c) 2015-2018, HiQDev (http://hiqdev.com/)
9
 */
10
11
namespace hidev\components;
12
13
/**
14
 * Git component.
15
 */
16
class Git extends AbstractVcs
17
{
18
    public $ignorefile = '.gitignore';
19
20
    /**
21
     * @var string current tag
22
     */
23
    protected $tag;
24
25
    public function getUserName()
26
    {
27
        return trim(`git config --get user.name`);
28
    }
29
30
    public function getUserEmail()
31
    {
32
        return trim(`git config --get user.email`);
33
    }
34
35
    public function getYear()
36
    {
37
        $date = `git log --reverse --pretty=%ai | head -n 1`;
38
        $year = $date ? date('Y', strtotime($date)) : '';
39
40
        return $year;
41
    }
42
43
    public function commit($message)
44
    {
45
        return $this->passthru('git', ['commit', '-am', $message]);
46
    }
47
48
    public function tag($tag)
49
    {
50
        return $this->passthru('git', ['tag', $tag]);
51
    }
52
53
    public function push()
54
    {
55
        $res = $this->passthru('git', ['push']);
56
        if ($res) {
57
            return $res;
58
        }
59
60
        return $this->passthru('git', ['push', '--tags']);
61
    }
62
}
63