Completed
Push — master ( b4a6ad...e2bab1 )
by Andrii
13:50
created

GithubController   A

Complexity

Total Complexity 13

Size/Duplication

Total Lines 66
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 1

Importance

Changes 2
Bugs 0 Features 0
Metric Value
wmc 13
c 2
b 0
f 0
lcom 1
cbo 1
dl 0
loc 66
rs 10

8 Methods

Rating   Name   Duplication   Size   Complexity  
A setName() 0 7 3
A getName() 0 8 2
A setVendor() 0 4 1
A getVendor() 0 8 2
A actionCreate() 0 3 1
A setPackage() 0 4 1
A getPackage() 0 8 2
A actionClone() 0 4 1
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) 2014-2016, HiQDev (http://hiqdev.com/)
10
 */
11
12
namespace hidev\controllers;
13
14
/**
15
 * Goal for GitHub.
16
 */
17
class GithubController extends CommonController
18
{
19
    protected $_name;
20
    protected $_vendor;
21
    protected $_package;
22
23
    public function setName($value)
24
    {
25
        list($vendor, $package) = explode('/', $value, 2);
26
        $this->_name    = $value;
27
        $this->_vendor  = $vendor ?: $package;
28
        $this->_package = $package ?: $vendor;
29
    }
30
31
    public function getName()
32
    {
33
        if ($this->_name === null) {
34
            $this->setName($this->takeGoal('package')->fullName);
35
        }
36
37
        return $this->_name;
38
    }
39
40
    public function setVendor($value)
41
    {
42
        $this->_vendor = $value;
43
    }
44
45
    public function getVendor()
46
    {
47
        if ($this->_vendor === null) {
48
            $this->_vendor = $this->getVendor()->name;
49
        }
50
51
        return $this->_vendor;
52
    }
53
54
    public function actionCreate()
55
    {
56
    }
57
58
    public function setPackage($value)
59
    {
60
        $this->_package = $value;
61
    }
62
63
    public function getPackage()
64
    {
65
        if ($this->_package === null) {
66
            $this->_package = $this->takeGoal('package')->name;
67
        }
68
69
        return $this->_package;
70
    }
71
72
    /**
73
     * Clone repo from github.
74
     * TODO to work need to redo HiDev to run this action without normal initilization.
75
     * @param string $repo full name vendor/package
76
     * @return int exit code
77
     */
78
    public function actionClone($repo)
79
    {
80
        return $this->passthru('git', ['clone', '[email protected]:' . $repo]);
0 ignored issues
show
Documentation introduced by
array('clone', '[email protected]:' . $repo) is of type array<integer,string,{"0":"string","1":"string"}>, 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...
81
    }
82
}
83