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

TestingKernel::boot()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 0
Metric Value
cc 1
eloc 1
nc 1
nop 1
dl 0
loc 3
ccs 0
cts 3
cp 0
crap 2
rs 10
c 0
b 0
f 0
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