df8e1501e0fd37fd564ebdc18319775215e420c4
[Packages/TYPO3.CMS.git] / typo3 / sysext / extbase / Tests / Unit / Reflection / Fixture / ArrayAccessClass.php
1 <?php
2 namespace TYPO3\CMS\Extbase\Tests\Unit\Reflection\Fixture;
3
4 /*
5 * This file is part of the TYPO3 CMS project.
6 *
7 * It is free software; you can redistribute it and/or modify it under
8 * the terms of the GNU General Public License, either version 2
9 * of the License, or any later version.
10 *
11 * For the full copyright and license information, please read the
12 * LICENSE.txt file that was distributed with this source code.
13 *
14 * The TYPO3 project - inspiring people to share!
15 */
16
17 /**
18 * ArrayAccess class for the Reflection tests
19 *
20 * @license http://www.gnu.org/licenses/lgpl.html GNU Lesser General Public License, version 3 or later
21 */
22 class ArrayAccessClass implements \ArrayAccess
23 {
24 /**
25 * @var array
26 */
27 protected $array = [];
28
29 /**
30 * @param array $array
31 */
32 public function __construct(array $array)
33 {
34 $this->array = $array;
35 }
36
37 /**
38 * @param mixed $offset
39 * @return bool
40 */
41 public function offsetExists($offset)
42 {
43 return array_key_exists($offset, $this->array);
44 }
45
46 /**
47 * @param mixed $offset
48 * @return mixed
49 */
50 public function offsetGet($offset)
51 {
52 return $this->array[$offset];
53 }
54
55 /**
56 * @param mixed $offset
57 * @param mixed $value
58 */
59 public function offsetSet($offset, $value)
60 {
61 $this->array[$offset] = $value;
62 }
63
64 /**
65 * @param mixed $offset
66 */
67 public function offsetUnset($offset)
68 {
69 unset($this->array[$offset]);
70 }
71
72 /**
73 * @return mixed
74 */
75 public function getVirtual()
76 {
77 return isset($this->array['virtual']) ? $this->array['virtual'] : 'default-value';
78 }
79 }