ArrayAdapter   A
last analyzed

Complexity

Total Complexity 5

Size/Duplication

Total Lines 47
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
wmc 5
eloc 7
dl 0
loc 47
rs 10
c 0
b 0
f 0

5 Methods

Rating   Name   Duplication   Size   Complexity  
A offsetGet() 0 3 1
A offsetUnset() 0 3 1
A offsetExists() 0 3 1
A offsetSet() 0 3 1
A __construct() 0 3 1
1
<?php declare(strict_types=1);
2
3
namespace Stratadox\Di;
4
5
use ArrayAccess;
6
use Closure;
7
use Psr\Container\NotFoundExceptionInterface as NotFound;
8
9
final class ArrayAdapter implements ArrayAccess
10
{
11
    private $container;
12
13
    /**
14
     * @param Container $container
15
     */
16
    public function __construct(Container $container)
17
    {
18
        $this->container = $container;
19
    }
20
21
    /**
22
     * @param string $offset
23
     * @return bool
24
     */
25
    public function offsetExists($offset): bool
26
    {
27
        return $this->container->has($offset);
28
    }
29
30
    /**
31
     * @param string $offset
32
     * @return mixed
33
     * @throws InvalidServiceDefinition
34
     * @throws NotFound
35
     */
36
    public function offsetGet($offset)
37
    {
38
        return $this->container->get($offset);
39
    }
40
41
    /**
42
     * @param string $offset
43
     * @param Closure $value
44
     */
45
    public function offsetSet($offset, $value): void
46
    {
47
        $this->container->set($offset, $value);
48
    }
49
50
    /**
51
     * @param string $offset
52
     */
53
    public function offsetUnset($offset): void
54
    {
55
        $this->container->forget($offset);
56
    }
57
}
58