Completed
Push — master ( e15c58...b150a8 )
by Changwan
07:08
created

TestingKernel   A

Complexity

Total Complexity 6

Size/Duplication

Total Lines 36
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 2

Test Coverage

Coverage 0%

Importance

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

4 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 4 1
A boot() 0 3 1
A execute() 0 16 3
A result() 0 4 1
1
<?php
2
namespace Wandu\Foundation\Kernels;
3
4
use Wandu\Foundation\Contracts\KernelInterface;
5
use Wandu\DI\ContainerInterface;
6
use PHPUnit_Framework_Test;
7
use Wandu\DI\Exception\CannotInjectException;
8
9
class TestingKernel implements KernelInterface
0 ignored issues
show
Bug introduced by
There is at least one abstract method in this class. Maybe declare it as abstract, or implement the remaining methods: offsetExists, offsetGet, offsetSet, offsetUnset
Loading history...
10
{
11
    /** @var \PHPUnit_Framework_Test */
12
    protected $test;
13
14
    public function __construct(PHPUnit_Framework_Test $test)
15
    {
16
        $this->test = $test;
17
    }
18
19
    public function boot(ContainerInterface $app)
20
    {
21
    }
22
23
    public function execute(ContainerInterface $app)
24
    {
25
        try {
26
            $app->inject($this->test);
27
        } catch (CannotInjectException $exception) {
28
            $propertyName = $exception->getProperty();
29
            $className = $exception->getClass();
30
            if (class_exists($className)) {
31
                $app->inject($this->test, [
32
                    $propertyName => $app->create($className)
33
                ]);
34
            } else {
35
                throw $exception;
36
            }
37
        }
38
    }
39
40
    public function result()
41
    {
42
        return 0;
43
    }
44
}
45