Completed
Push — master ( 7c373b...4a176f )
by Andrii
07:48
created

ScrutinizerPythonController::actionGetOcular()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 8
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 6

Importance

Changes 1
Bugs 0 Features 1
Metric Value
dl 0
loc 8
ccs 0
cts 7
cp 0
rs 9.4285
c 1
b 0
f 1
cc 2
eloc 4
nc 2
nop 0
crap 6
1
<?php
2
3
/*
4
 * Scrutinizer plugin for HiDev
5
 *
6
 * @link      https://github.com/hiqdev/hidev-scrutinizer
7
 * @package   hidev-scrutinizer
8
 * @license   BSD-3-Clause
9
 * @copyright Copyright (c) 2015-2016, HiQDev (http://hiqdev.com/)
10
 */
11
12
namespace hidev\scrutinizer\controllers;
13
14
/**
15
 * Scrutinizer for Python.
16
 */
17
class ScrutinizerPythonController extends \hidev\controllers\CommonController
18
{
19
    public function actionUploadCoverage()
20
    {
21
        return $this->runActions(['get-ocular', 'run-ocular']);
22
    }
23
24
    public function actionGetOcular()
25
    {
26
        if (!$this->execCode('python',['-c', 'import scrutinizer.ocular'], true)) {
0 ignored issues
show
Documentation Bug introduced by
The method execCode does not exist on object<hidev\scrutinizer...inizerPythonController>? Since you implemented __call, maybe consider adding a @method annotation.

If you implement __call and you know which methods are available, you can improve IDE auto-completion and static analysis by adding a @method annotation to the class.

This is often the case, when __call is implemented by a parent class and only the child class knows which methods exist:

class ParentClass {
    private $data = array();

    public function __call($method, array $args) {
        if (0 === strpos($method, 'get')) {
            return $this->data[strtolower(substr($method, 3))];
        }

        throw new \LogicException(sprintf('Unsupported method: %s', $method));
    }
}

/**
 * If this class knows which fields exist, you can specify the methods here:
 *
 * @method string getName()
 */
class SomeClass extends ParentClass { }
Loading history...
27
            return 0;
28
        }
29
30
        return $this->passthru('pip', ['install', 'scrutinizer-ocular']);
31
    }
32
33
    public function actionRunOcular()
34
    {
35
        return $this->passthru('ocular', ['--data-file', '.coverage']);
36
    }
37
}
38