‪TYPO3CMS  11.5
ArrayAccessClass.php
Go to the documentation of this file.
1 <?php
2 
3 declare(strict_types=1);
4 
5 /*
6  * This file is part of the TYPO3 CMS project.
7  *
8  * It is free software; you can redistribute it and/or modify it under
9  * the terms of the GNU General Public License, either version 2
10  * of the License, or any later version.
11  *
12  * For the full copyright and license information, please read the
13  * LICENSE.txt file that was distributed with this source code.
14  *
15  * The TYPO3 project - inspiring people to share!
16  */
17 
19 
23 class ‪ArrayAccessClass implements \ArrayAccess
24 {
25  protected array ‪$array = [];
26 
30  public function ‪__construct(array ‪$array)
31  {
32  $this->array = ‪$array;
33  }
34 
40  public function ‪offsetExists($offset): bool
41  {
42  return array_key_exists($offset, $this->array);
43  }
44 
51  #[\ReturnTypeWillChange]
52  public function ‪offsetGet($offset)
53  {
54  return $this->array[$offset];
55  }
56 
62  public function ‪offsetSet($offset, $value): void
63  {
64  $this->array[$offset] = $value;
65  }
66 
70  public function ‪offsetUnset($offset): void
71  {
72  unset($this->array[$offset]);
73  }
74 
78  public function ‪getVirtual()
79  {
80  return $this->array['virtual'] ?? 'default-value';
81  }
82 }
‪TYPO3\CMS\Extbase\Tests\Unit\Reflection\Fixture
Definition: ArrayAccessClass.php:18
‪TYPO3\CMS\Extbase\Tests\Unit\Reflection\Fixture\ArrayAccessClass\offsetSet
‪offsetSet($offset, $value)
Definition: ArrayAccessClass.php:62
‪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:70
‪TYPO3\CMS\Extbase\Tests\Unit\Reflection\Fixture\ArrayAccessClass\getVirtual
‪mixed getVirtual()
Definition: ArrayAccessClass.php:78
‪TYPO3\CMS\Extbase\Tests\Unit\Reflection\Fixture\ArrayAccessClass\offsetGet
‪mixed offsetGet($offset)
Definition: ArrayAccessClass.php:52
‪TYPO3\CMS\Extbase\Tests\Unit\Reflection\Fixture\ArrayAccessClass
Definition: ArrayAccessClass.php:24
‪TYPO3\CMS\Extbase\Tests\Unit\Reflection\Fixture\ArrayAccessClass\offsetExists
‪bool offsetExists($offset)
Definition: ArrayAccessClass.php:40