|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
namespace Geekish\Slimbox; |
|
4
|
|
|
|
|
5
|
|
|
use ArrayAccess; |
|
6
|
|
|
use BadMethodCallException; |
|
7
|
|
|
use mindplay\unbox\Configuration; |
|
8
|
|
|
use mindplay\unbox\Container as Unbox; |
|
9
|
|
|
use mindplay\unbox\ContainerException; |
|
10
|
|
|
|
|
11
|
|
|
final class Container extends Unbox implements ArrayAccess |
|
12
|
|
|
{ |
|
13
|
|
|
/** |
|
14
|
|
|
* @param Configuration $config |
|
15
|
|
|
*/ |
|
16
|
|
|
public function __construct(Configuration $config) |
|
17
|
|
|
{ |
|
18
|
|
|
parent::__construct($config); |
|
19
|
|
|
} |
|
20
|
|
|
|
|
21
|
|
|
/******************************************************************************** |
|
22
|
|
|
* ArrayAccess interface |
|
23
|
|
|
*******************************************************************************/ |
|
24
|
|
|
|
|
25
|
|
|
/** |
|
26
|
|
|
* @inheritDoc |
|
27
|
|
|
*/ |
|
28
|
|
|
public function offsetExists($key) |
|
29
|
|
|
{ |
|
30
|
|
|
return $this->has($key); |
|
31
|
|
|
} |
|
32
|
|
|
|
|
33
|
|
|
/** |
|
34
|
|
|
* @inheritDoc |
|
35
|
|
|
*/ |
|
36
|
|
|
public function offsetGet($key) |
|
37
|
|
|
{ |
|
38
|
|
|
return $this->get($key); |
|
39
|
|
|
} |
|
40
|
|
|
|
|
41
|
|
|
/** |
|
42
|
|
|
* @inheritDoc |
|
43
|
|
|
*/ |
|
44
|
|
|
public function offsetSet($key, $value) |
|
45
|
|
|
{ |
|
46
|
|
|
throw new BadMethodCallException(sprintf( |
|
47
|
|
|
"%s does not support ArrayAccess::offsetSet, you must use %s to configure and create the container", |
|
48
|
|
|
__CLASS__, |
|
49
|
|
|
ContainerFactory::class |
|
50
|
|
|
)); |
|
51
|
|
|
} |
|
52
|
|
|
|
|
53
|
|
|
/** |
|
54
|
|
|
* @inheritDoc |
|
55
|
|
|
*/ |
|
56
|
|
|
public function offsetUnset($key) |
|
57
|
|
|
{ |
|
58
|
|
|
throw new BadMethodCallException(sprintf( |
|
59
|
|
|
"%s does not support ArrayAccess::offsetUnset(), you must use %s to configure and create the container", |
|
60
|
|
|
__CLASS__, |
|
61
|
|
|
ContainerFactory::class |
|
62
|
|
|
)); |
|
63
|
|
|
} |
|
64
|
|
|
|
|
65
|
|
|
/******************************************************************************** |
|
66
|
|
|
* Slim Container "compatibility" |
|
67
|
|
|
*******************************************************************************/ |
|
68
|
|
|
|
|
69
|
|
|
/** |
|
70
|
|
|
* @inheritDoc |
|
71
|
|
|
*/ |
|
72
|
|
|
public function set($key, $value) |
|
|
|
|
|
|
73
|
|
|
{ |
|
74
|
|
|
throw new BadMethodCallException(sprintf( |
|
75
|
|
|
"%s does not support set() method, you must use %s to configure and create the container", |
|
76
|
|
|
__CLASS__, |
|
77
|
|
|
ContainerFactory::class |
|
78
|
|
|
)); |
|
79
|
|
|
} |
|
80
|
|
|
} |
|
81
|
|
|
|
This check looks from parameters that have been defined for a function or method, but which are not used in the method body.