Passed
Pull Request — master (#32)
by Wilmer
14:34
created

FakeContainer::get()   A

Complexity

Conditions 3
Paths 3

Size

Total Lines 9
Code Lines 5

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 3
eloc 5
c 0
b 0
f 0
nc 3
nop 1
dl 0
loc 9
rs 10
1
<?php
2
3
namespace Yiisoft\Yii\Cycle\Tests\Conveyor\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