‪TYPO3CMS  10.4
ArrayAccessClass.php
Go to the documentation of this file.
1 <?php
2 
3 /*
4  * This file is part of the TYPO3 CMS project.
5  *
6  * It is free software; you can redistribute it and/or modify it under
7  * the terms of the GNU General Public License, either version 2
8  * of the License, or any later version.
9  *
10  * For the full copyright and license information, please read the
11  * LICENSE.txt file that was distributed with this source code.
12  *
13  * The TYPO3 project - inspiring people to share!
14  */
15 
17 
21 class ‪ArrayAccessClass implements \ArrayAccess
22 {
26  protected ‪$array = [];
27 
31  public function ‪__construct(array ‪$array)
32  {
33  $this->array = ‪$array;
34  }
35 
40  public function ‪offsetExists($offset)
41  {
42  return array_key_exists($offset, $this->array);
43  }
44 
49  public function ‪offsetGet($offset)
50  {
51  return $this->array[$offset];
52  }
53 
58  public function ‪offsetSet($offset, $value)
59  {
60  $this->array[$offset] = $value;
61  }
62 
66  public function ‪offsetUnset($offset)
67  {
68  unset($this->array[$offset]);
69  }
70 
74  public function ‪getVirtual()
75  {
76  return $this->array['virtual'] ?? 'default-value';
77  }
78 }
‪TYPO3\CMS\Extbase\Tests\Unit\Reflection\Fixture
Definition: ArrayAccessClass.php:16
‪TYPO3\CMS\Extbase\Tests\Unit\Reflection\Fixture\ArrayAccessClass\offsetSet
‪offsetSet($offset, $value)
Definition: ArrayAccessClass.php:57
‪TYPO3\CMS\Extbase\Tests\Unit\Reflection\Fixture\ArrayAccessClass\__construct
‪__construct(array $array)
Definition: ArrayAccessClass.php:30
‪TYPO3\CMS\Extbase\Tests\Unit\Reflection\Fixture\ArrayAccessClass\$array
‪array $array
Definition: ArrayAccessClass.php:25
‪TYPO3\CMS\Extbase\Tests\Unit\Reflection\Fixture\ArrayAccessClass\offsetUnset
‪offsetUnset($offset)
Definition: ArrayAccessClass.php:65
‪TYPO3\CMS\Extbase\Tests\Unit\Reflection\Fixture\ArrayAccessClass\getVirtual
‪mixed getVirtual()
Definition: ArrayAccessClass.php:73
‪TYPO3\CMS\Extbase\Tests\Unit\Reflection\Fixture\ArrayAccessClass\offsetGet
‪mixed offsetGet($offset)
Definition: ArrayAccessClass.php:48
‪TYPO3\CMS\Extbase\Tests\Unit\Reflection\Fixture\ArrayAccessClass
Definition: ArrayAccessClass.php:22
‪TYPO3\CMS\Extbase\Tests\Unit\Reflection\Fixture\ArrayAccessClass\offsetExists
‪bool offsetExists($offset)
Definition: ArrayAccessClass.php:39