Bitrix-D7 23.9
 
Загрузка...
Поиск...
Не найдено
dictionary.php
1<?php
2namespace Bitrix\Main\Type;
3
5 implements \ArrayAccess, \Iterator, \Countable, \JsonSerializable
6{
10 protected $values = [];
11
17 public function __construct(array $values = null)
18 {
19 if($values !== null)
20 {
21 $this->values = $values;
22 }
23 }
24
31 public function get($name)
32 {
33 // this condition a bit faster
34 // it is possible to omit array_key_exists here, but for uniformity...
35 if (isset($this->values[$name]) || \array_key_exists($name, $this->values))
36 {
37 return $this->values[$name];
38 }
39
40 return null;
41 }
42
43 public function set($name, $value = null)
44 {
45 if (\is_array($name))
46 {
47 $this->values = $name;
48 }
49 else
50 {
51 $this[$name] = $value;
52 }
53 }
54
58 public function getValues()
59 {
60 return $this->values;
61 }
62
66 public function setValues($values)
67 {
68 $this->values = $values;
69 }
70
71 public function clear()
72 {
73 $this->values = [];
74 }
75
81 #[\ReturnTypeWillChange]
82 public function current()
83 {
84 return current($this->values);
85 }
86
92 public function next(): void
93 {
94 next($this->values);
95 }
96
102 #[\ReturnTypeWillChange]
103 public function key()
104 {
105 return key($this->values);
106 }
107
113 public function valid(): bool
114 {
115 return ($this->key() !== null);
116 }
117
123 public function rewind(): void
124 {
125 reset($this->values);
126 }
127
133 public function offsetExists($offset): bool
134 {
135 return isset($this->values[$offset]) || \array_key_exists($offset, $this->values);
136 }
137
143 #[\ReturnTypeWillChange]
144 public function offsetGet($offset)
145 {
146 if (isset($this->values[$offset]) || \array_key_exists($offset, $this->values))
147 {
148 return $this->values[$offset];
149 }
150
151 return null;
152 }
153
159 #[\ReturnTypeWillChange]
160 public function offsetSet($offset, $value)
161 {
162 if($offset === null)
163 {
164 $this->values[] = $value;
165 }
166 else
167 {
168 $this->values[$offset] = $value;
169 }
170 }
171
177 public function offsetUnset($offset): void
178 {
179 unset($this->values[$offset]);
180 }
181
187 public function count(): int
188 {
189 return \count($this->values);
190 }
191
197 public function toArray()
198 {
199 return $this->values;
200 }
201
206 public function isEmpty()
207 {
208 return empty($this->values);
209 }
210
215 #[\ReturnTypeWillChange]
216 public function jsonSerialize()
217 {
218 return $this->values;
219 }
220}
__construct(array $values=null)
offsetSet($offset, $value)