Passed
Push — master ( ee28da...1c3e2f )
by Alexander
14:20 queued 13:06
created

FakeContainer   A

Complexity

Total Complexity 5

Size/Duplication

Total Lines 20
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 9
c 1
b 0
f 0
dl 0
loc 20
rs 10
wmc 5

3 Methods

Rating   Name   Duplication   Size   Complexity  
A has() 0 3 1
A __construct() 0 3 1
A get() 0 9 3
1
<?php
2
3
namespace Yiisoft\Yii\Cycle\Tests\Generator\Stub;
4
5
use Cycle\Schema\GeneratorInterface;
6
use PHPUnit\Framework\TestCase;
7
use Psr\Container\ContainerInterface;
8
use Yiisoft\Aliases\Aliases;
9
10
class FakeContainer implements ContainerInterface
11
{
12
    private TestCase $testCase;
13
    public function __construct(TestCase $testCase)
14
    {
15
        $this->testCase = $testCase;
16
    }
17
    public function get($id)
18
    {
19
        if ($id === Aliases::class) {
20
            return new Aliases(['@test-dir' => __DIR__]);
21
        }
22
        if (is_a($id, GeneratorInterface::class, true)) {
23
            return new FakeGenerator($id);
24
        }
25
        return $this->testCase->getMockBuilder($id)->getMock();
26
    }
27
    public function has($id)
28
    {
29
        return true;
30
    }
31
}
32