PytestController::actionMake()   A
last analyzed

Complexity

Conditions 2
Paths 2

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 6

Importance

Changes 1
Bugs 0 Features 1
Metric Value
c 1
b 0
f 1
dl 0
loc 4
ccs 0
cts 4
cp 0
rs 10
cc 2
eloc 2
nc 2
nop 0
crap 6
1
<?php
2
3
/*
4
 * pytest plugin for HiDev
5
 *
6
 * @link      https://github.com/hiqdev/hidev-pytest
7
 * @package   hidev-pytest
8
 * @license   BSD-3-Clause
9
 * @copyright Copyright (c) 2016, HiQDev (http://hiqdev.com/)
10
 */
11
12
namespace hidev\pytest\console;
13
14
/**
15
 * Goal for Pytest.
16
 */
17
class PytestController extends \hidev\controllers\CommonController
18
{
19
    protected $_version;
20
21
    public $coverage;
22
23
    public function actionMake()
24
    {
25
        return $this->coverage ? $this->actionCoverage() : $this->actionRun();
26
    }
27
28
    public function actionCoverage()
29
    {
30
        $args = ['run', '-m', 'pytest'];
31
32
        return $this->passthru('coverage', $args);
33
    }
34
35
    public function actionRun()
36
    {
37
        $args = [];
38
39
        return $this->passthru('pytest', $args);
40
    }
41
42
    public function getVersion()
43
    {
44
        if ($this->_version === null) {
45
            $lines = $this->exec('phpunit', ['--version']);
46
            $a = explode(' ', $lines[0], 6)[4];
47
            $this->_version = $a;
48
        }
49
50
        return $this->_version;
51
    }
52
}
53