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

FakeContainer   A

Complexity

Total Complexity 5

Size/Duplication

Total Lines 20
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
eloc 9
c 0
b 0
f 0
dl 0
loc 20
rs 10
wmc 5
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