Passed
Pull Request — master (#610)
by John
05:33
created

TestRunner   A

Complexity

Total Complexity 8

Size/Duplication

Total Lines 28
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 1
Metric Value
eloc 18
dl 0
loc 28
rs 10
c 1
b 0
f 1
wmc 8

2 Methods

Rating   Name   Duplication   Size   Complexity  
A create() 0 16 5
A __construct() 0 5 3
1
<?php
2
3
namespace App\Babel\TestRun;
4
5
use ErrorException;
6
use Exception;
7
use Throwable;
8
9
class TestRunner
10
{
11
    public $verdict=null;
12
13
    public function __construct($conf)
14
    {
15
        $runner=self::create($conf);
16
        if (!is_null($runner) && isset($runner)) {
17
            $this->verdict=$runner->run();
18
        }
19
    }
20
21
    public static function create($conf)
22
    {
23
        $name=$conf["name"];
24
        $runnerProvider="TestRunner";
25
        try {
26
            $BabelConfig=json_decode(file_get_contents(babel_path("Extension/$name/babel.json")), true);
27
            $runnerProvider=$BabelConfig["provider"]["testrunner"];
28
        } catch (Throwable $e) {
0 ignored issues
show
Coding Style Comprehensibility introduced by
Consider adding a comment why this CATCH block is empty.
Loading history...
29
        } catch (ErrorException $e) {
0 ignored issues
show
Coding Style Comprehensibility introduced by
Consider adding a comment why this CATCH block is empty.
Loading history...
30
        } catch (Exception $e) {
0 ignored issues
show
Coding Style Comprehensibility introduced by
Consider adding a comment why this CATCH block is empty.
Loading history...
31
        }
32
        $className="App\\Babel\\Extension\\$name\\$runnerProvider";
33
        if (class_exists($className)) {
34
            return new $className($conf);
35
        } else {
36
            return null;
37
        }
38
    }
39
}
40