PytestController   A
last analyzed

Complexity

Total Complexity 6

Size/Duplication

Total Lines 36
Duplicated Lines 0 %

Coupling/Cohesion

Components 2
Dependencies 0

Test Coverage

Coverage 0%

Importance

Changes 1
Bugs 0 Features 1
Metric Value
wmc 6
c 1
b 0
f 1
lcom 2
cbo 0
dl 0
loc 36
ccs 0
cts 23
cp 0
rs 10

4 Methods

Rating   Name   Duplication   Size   Complexity  
A actionMake() 0 4 2
A actionCoverage() 0 6 1
A actionRun() 0 6 1
A getVersion() 0 10 2
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