Passed
Pull Request — master (#2)
by Alexander
01:11
created

DummyContainer   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 16
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 3
eloc 6
c 1
b 0
f 0
dl 0
loc 16
rs 10

2 Methods

Rating   Name   Duplication   Size   Complexity  
A get() 0 7 2
A has() 0 3 1
1
<?php
2
3
4
namespace Yiisoft\Proxy\Tests;
5
6
7
use Psr\Container\ContainerInterface;
8
9
final class DummyContainer implements ContainerInterface
10
{
11
    private array $instances = [];
12
13
    public function get($id)
14
    {
15
        if ($id === Proxied::class) {
16
            return $this->instances[$id] ?? ($this->instances[$id] = new Proxied());
17
        }
18
19
        throw new NotFoundException("$id not found in container.");
20
    }
21
22
    public function has($id): bool
23
    {
24
        return $id === Proxied::class;
25
    }
26
}
27