scratch – Blame information for rev 120
?pathlinks?
Rev | Author | Line No. | Line |
---|---|---|---|
120 | office | 1 | <?php |
2 | |||
3 | /* |
||
4 | * This file is part of Alchemy\BinaryDriver. |
||
5 | * |
||
6 | * (c) Alchemy <info@alchemy.fr> |
||
7 | * |
||
8 | * For the full copyright and license information, please view the LICENSE |
||
9 | * file that was distributed with this source code. |
||
10 | */ |
||
11 | |||
12 | namespace Alchemy\BinaryDriver; |
||
13 | |||
14 | class Configuration implements ConfigurationInterface |
||
15 | { |
||
16 | private $data; |
||
17 | |||
18 | public function __construct(array $data = array()) |
||
19 | { |
||
20 | $this->data = $data; |
||
21 | } |
||
22 | |||
23 | /** |
||
24 | * {@inheritdoc} |
||
25 | */ |
||
26 | public function getIterator() |
||
27 | { |
||
28 | return new \ArrayIterator($this->data); |
||
29 | } |
||
30 | |||
31 | /** |
||
32 | * {@inheritdoc} |
||
33 | */ |
||
34 | public function get($key, $default = null) |
||
35 | { |
||
36 | return isset($this->data[$key]) ? $this->data[$key] : $default; |
||
37 | } |
||
38 | |||
39 | /** |
||
40 | * {@inheritdoc} |
||
41 | */ |
||
42 | public function set($key, $value) |
||
43 | { |
||
44 | $this->data[$key] = $value; |
||
45 | |||
46 | return $this; |
||
47 | } |
||
48 | |||
49 | /** |
||
50 | * {@inheritdoc} |
||
51 | */ |
||
52 | public function has($key) |
||
53 | { |
||
54 | return array_key_exists($key, $this->data); |
||
55 | } |
||
56 | |||
57 | /** |
||
58 | * {@inheritdoc} |
||
59 | */ |
||
60 | public function remove($key) |
||
61 | { |
||
62 | $value = $this->get($key); |
||
63 | unset($this->data[$key]); |
||
64 | |||
65 | return $value; |
||
66 | } |
||
67 | |||
68 | /** |
||
69 | * {@inheritdoc} |
||
70 | */ |
||
71 | public function all() |
||
72 | { |
||
73 | return $this->data; |
||
74 | } |
||
75 | |||
76 | /** |
||
77 | * {@inheritdoc} |
||
78 | */ |
||
79 | public function offsetExists($offset) |
||
80 | { |
||
81 | return $this->has($offset); |
||
82 | } |
||
83 | |||
84 | /** |
||
85 | * {@inheritdoc} |
||
86 | */ |
||
87 | public function offsetGet($offset) |
||
88 | { |
||
89 | return $this->get($offset); |
||
90 | } |
||
91 | |||
92 | /** |
||
93 | * {@inheritdoc} |
||
94 | */ |
||
95 | public function offsetSet($offset, $value) |
||
96 | { |
||
97 | $this->set($offset, $value); |
||
98 | } |
||
99 | |||
100 | /** |
||
101 | * {@inheritdoc} |
||
102 | */ |
||
103 | public function offsetUnset($offset) |
||
104 | { |
||
105 | $this->remove($offset); |
||
106 | } |
||
107 | } |