Completed
Push — master ( a13e0c...77f861 )
by Andrii
05:45
created

GitController   A

Complexity

Total Complexity 8

Size/Duplication

Total Lines 52
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 1

Test Coverage

Coverage 0%

Importance

Changes 0
Metric Value
wmc 8
lcom 1
cbo 1
dl 0
loc 52
ccs 0
cts 4
cp 0
rs 10
c 0
b 0
f 0

7 Methods

Rating   Name   Duplication   Size   Complexity  
A actionCommit() 0 4 1
A actionRelease() 0 9 1
A actionTag() 0 4 1
A actionPush() 0 4 1
A getUserName() 0 4 1
A getUserEmail() 0 4 1
A getYear() 0 7 2
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-2017, HiQDev (http://hiqdev.com/)
9
 */
10
11
namespace hidev\controllers;
12
13
/**
14
 * Controller for Git.
15
 */
16
class GitController extends VcsController
17
{
18
    protected $_before = ['.gitignore'];
19
20
    /**
21
     * @var string current tag
22
     */
23
    protected $tag;
24
25
    public function actionRelease($version = null)
26
    {
27
        $version = $this->takeGoal('version')->getVersion($version);
28
        $message = "version bump to $version";
29
        $this->actionCommit($message);
30
        $this->actionTag($version);
31
32
        return $this->actionPush();
33
    }
34
35
    public function actionCommit($message)
36
    {
37
        return $this->passthru('git', ['commit', '-am', $message]);
38
    }
39
40
    public function actionTag($tag)
41
    {
42
        return $this->passthru('git', ['tag', $tag]);
43
    }
44
45
    public function actionPush()
46
    {
47
        return $this->passthru('git', 'push', '--tags');
0 ignored issues
show
Unused Code introduced by
The call to GitController::passthru() has too many arguments starting with '--tags'.

This check compares calls to functions or methods with their respective definitions. If the call has more arguments than are defined, it raises an issue.

If a function is defined several times with a different number of parameters, the check may pick up the wrong definition and report false positives. One codebase where this has been known to happen is Wordpress.

In this case you can add the @ignore PhpDoc annotation to the duplicate definition and it will be ignored.

Loading history...
48
    }
49
50
    public function getUserName()
51
    {
52
        return trim(`git config --get user.name`);
53
    }
54
55
    public function getUserEmail()
56
    {
57
        return trim(`git config --get user.email`);
58
    }
59
60
    public function getYear()
61
    {
62
        $date = `git log --reverse --pretty=%ai | head -n 1`;
63
        $year = $date ? date('Y', strtotime($date)) : '';
64
65
        return $year;
66
    }
67
}
68