Completed
Push — master ( 4141d9...f493e8 )
by Andrii
02:47
created

BinariesController   A

Complexity

Total Complexity 6

Size/Duplication

Total Lines 42
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 2

Importance

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

3 Methods

Rating   Name   Duplication   Size   Complexity  
A actionMake() 0 11 4
A getItemConfig() 0 7 1
A passthru() 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
class BinariesController extends CommonController
15
{
16
    use \hiqdev\yii2\collection\ManagerTrait;
17
18
    protected $_before = ['start'];
19
20
    public $defaultClass = 'hidev\base\BinaryPhp';
21
22
    public function actionMake()
23
    {
24
        foreach ($this->getItems() as $name => $bin) {
25
            if (!$bin->detectPath($name)) {
26
                $exitcode = $bin->install();
27
                if ($exitcode) {
28
                    return $exitcode;
29
                }
30
            }
31
        }
32
    }
33
34
    /**
35
     * Prepares item config.
36
     */
37
    public function getItemConfig($name = null, array $config = [])
38
    {
39
        return array_merge([
40
            'name'  => $name,
41
            'class' => $this->defaultClass,
42
        ], $config);
43
    }
44
45
    /**
46
     * Prepares and runs with passthru.
47
     * @param string $name binary
48
     * @param string $args
49
     * @return int exit code
50
     */
51
    public function passthru($name, $args = [])
52
    {
53
        return $this->get($name)->passthru($args);
54
    }
55
}
56