‪TYPO3CMS  9.5
ArrayAccessClass.php
Go to the documentation of this file.
1 <?php
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 
20 class ‪ArrayAccessClass implements \ArrayAccess
21 {
25  protected ‪$array = [];
26 
30  public function ‪__construct(array ‪$array)
31  {
32  $this->array = ‪$array;
33  }
34 
39  public function ‪offsetExists($offset)
40  {
41  return array_key_exists($offset, $this->array);
42  }
43 
48  public function ‪offsetGet($offset)
49  {
50  return $this->array[$offset];
51  }
52 
57  public function ‪offsetSet($offset, $value)
58  {
59  $this->array[$offset] = $value;
60  }
61 
65  public function ‪offsetUnset($offset)
66  {
67  unset($this->array[$offset]);
68  }
69 
73  public function ‪getVirtual()
74  {
75  return $this->array['virtual'] ?? 'default-value';
76  }
77 }
‪TYPO3\CMS\Extbase\Tests\Unit\Reflection\Fixture
Definition: ArrayAccessClass.php:2
‪TYPO3\CMS\Extbase\Tests\Unit\Reflection\Fixture\ArrayAccessClass\offsetSet
‪offsetSet($offset, $value)
Definition: ArrayAccessClass.php:56
‪TYPO3\CMS\Extbase\Tests\Unit\Reflection\Fixture\ArrayAccessClass\__construct
‪__construct(array $array)
Definition: ArrayAccessClass.php:29
‪TYPO3\CMS\Extbase\Tests\Unit\Reflection\Fixture\ArrayAccessClass\$array
‪array $array
Definition: ArrayAccessClass.php:24
‪TYPO3\CMS\Extbase\Tests\Unit\Reflection\Fixture\ArrayAccessClass\offsetUnset
‪offsetUnset($offset)
Definition: ArrayAccessClass.php:64
‪TYPO3\CMS\Extbase\Tests\Unit\Reflection\Fixture\ArrayAccessClass\getVirtual
‪mixed getVirtual()
Definition: ArrayAccessClass.php:72
‪TYPO3\CMS\Extbase\Tests\Unit\Reflection\Fixture\ArrayAccessClass\offsetGet
‪mixed offsetGet($offset)
Definition: ArrayAccessClass.php:47
‪TYPO3\CMS\Extbase\Tests\Unit\Reflection\Fixture\ArrayAccessClass
Definition: ArrayAccessClass.php:21
‪TYPO3\CMS\Extbase\Tests\Unit\Reflection\Fixture\ArrayAccessClass\offsetExists
‪bool offsetExists($offset)
Definition: ArrayAccessClass.php:38