Completed
Push — master ( fe52e0...52ea7e )
by Andrii
04:42
created

BumpController::setVersion()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 6
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 6

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 6
ccs 0
cts 6
cp 0
rs 9.4285
cc 2
eloc 3
nc 2
nop 1
crap 6
1
<?php
2
3
/*
4
 * Task runner, code generator and build tool for easier continuos integration
5
 *
6
 * @link      https://github.com/hiqdev/hidev
7
 * @package   hidev
8
 * @license   BSD-3-Clause
9
 * @copyright Copyright (c) 2015-2016, HiQDev (http://hiqdev.com/)
10
 */
11
12
namespace hidev\controllers;
13
14
/**
15
 * Controller for version bump.
16
 */
17
class BumpController extends AbstractController
18
{
19
    protected $_before = ['commits'];
20
21
    protected $_version;
22
23
    public function actionPerform($version = null)
24
    {
25
        $this->setVersion($version);
26
        return $this->perform();
27
    }
28
29
    public function actionMake()
30
    {
31
        return $this->runRequests(['commits/bump', 'version', 'CHANGELOG.md']);
0 ignored issues
show
Bug Compatibility introduced by
The expression $this->runRequests(array...ion', 'CHANGELOG.md')); of type integer|hidev\controllers\Response adds the type hidev\controllers\Response to the return on line 31 which is incompatible with the return type of the parent method hidev\controllers\AbstractController::actionMake of type null|integer.
Loading history...
32
    }
33
34
    public function actionCommit($version = null)
35
    {
36
        $version = $this->getVersion($version);
37
        $message = "version bump to $version";
38
        return $this->passthru('git', ['commit', '-am', $message]);
0 ignored issues
show
Documentation introduced by
array('commit', '-am', $message) is of type array<integer,?,{"0":"st...,"1":"string","2":"?"}>, but the function expects a string.

It seems like the type of the argument is not accepted by the function/method which you are calling.

In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug.

We suggest to add an explicit type cast like in the following example:

function acceptsInteger($int) { }

$x = '123'; // string "123"

// Instead of
acceptsInteger($x);

// we recommend to use
acceptsInteger((integer) $x);
Loading history...
39
    }
40
41
    public function setVersion($value)
42
    {
43
        if (isset($value)) {
44
            $this->_version = $value;
45
        }
46
    }
47
48
    public function getVersion($version = null)
49
    {
50
        return $version ?: $this->_version ?: $this->takeGoal('version')->version;
51
    }
52
53
    public function actionRelease($version = null)
54
    {
55
        $this->setVersion($version);
56
        return $this->runRequests(['bump/commit', 'git/push', 'github/release']);
57
    }
58
}
59