‪TYPO3CMS  ‪main
Map.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 
18 namespace ‪TYPO3\CMS\Core\Type;
19 
46 final class ‪Map implements \ArrayAccess, \Countable, \Iterator
47 {
48  private \SplObjectStorage ‪$storage;
49 
54  public static function ‪fromEntries(array ...$entries): self
55  {
56  $map = new self();
57  foreach ($entries as $entry) {
58  $map[$entry[0]] = $entry[1];
59  }
60  return $map;
61  }
62 
63  public function ‪__construct()
64  {
65  $this->storage = new \SplObjectStorage();
66  }
67 
68  public function ‪key(): mixed
69  {
70  return $this->storage->current();
71  }
72 
73  public function ‪current(): mixed
74  {
75  return $this->storage->getInfo();
76  }
77 
78  public function ‪next(): void
79  {
80  $this->storage->next();
81  }
82 
83  public function ‪rewind(): void
84  {
85  $this->storage->rewind();
86  }
87 
88  public function ‪valid(): bool
89  {
90  return $this->storage->valid();
91  }
92 
93  public function ‪offsetExists(mixed $offset): bool
94  {
95  return $this->storage->offsetExists($offset);
96  }
97 
98  public function ‪offsetGet(mixed $offset): mixed
99  {
100  if (!$this->‪offsetExists($offset)) {
101  return null;
102  }
103  return $this->storage->offsetGet($offset);
104  }
105 
106  public function ‪offsetSet(mixed $offset, mixed $value): void
107  {
108  $this->storage->offsetSet($offset, $value);
109  }
110 
111  public function ‪offsetUnset(mixed $offset): void
112  {
113  $this->storage->offsetUnset($offset);
114  }
115 
116  public function ‪count(): int
117  {
118  return ‪count($this->storage);
119  }
120 }
‪TYPO3\CMS\Core\Type\Map\__construct
‪__construct()
Definition: Map.php:63
‪TYPO3\CMS\Core\Type\Map\fromEntries
‪static fromEntries(array ... $entries)
Definition: Map.php:54
‪TYPO3\CMS\Core\Type\Map\count
‪count()
Definition: Map.php:116
‪TYPO3\CMS\Core\Type\Map\key
‪key()
Definition: Map.php:68
‪TYPO3\CMS\Core\Type\Map\offsetExists
‪offsetExists(mixed $offset)
Definition: Map.php:93
‪TYPO3\CMS\Core\Type\Map\rewind
‪rewind()
Definition: Map.php:83
‪TYPO3\CMS\Core\Type\Map\offsetSet
‪offsetSet(mixed $offset, mixed $value)
Definition: Map.php:106
‪TYPO3\CMS\Core\Type\Map\offsetGet
‪offsetGet(mixed $offset)
Definition: Map.php:98
‪TYPO3\CMS\Core\Type\Map\current
‪current()
Definition: Map.php:73
‪TYPO3\CMS\Core\Type\Map\next
‪next()
Definition: Map.php:78
‪TYPO3\CMS\Core\Type\Map
Definition: Map.php:47
‪TYPO3\CMS\Core\Type
‪TYPO3\CMS\Core\Type\Map\offsetUnset
‪offsetUnset(mixed $offset)
Definition: Map.php:111
‪TYPO3\CMS\Core\Type\Map\$storage
‪SplObjectStorage $storage
Definition: Map.php:48
‪TYPO3\CMS\Core\Type\Map\valid
‪valid()
Definition: Map.php:88