Debian Codegraph @

lib/3rdParty/composer/aws/aws-sdk-php/src/HasDataTrait.php

raw symbols SCIP
1 <?php
2 namespace Aws;
3
4 /**
5 * Trait implementing ToArrayInterface, \ArrayAccess, \Countable, and
6 * \IteratorAggregate
7 */
8 trait HasDataTrait
9 {
10 /** @var array */
11 private $data = [];
12
13 /**
14 * @return \Traversable
15 */
16 #[\ReturnTypeWillChange]
17 public function getIterator()
18 {
19 return new \ArrayIterator($this->data);
20 }
21
22 /**
23 * This method returns a reference to the variable to allow for indirect
24 * array modification (e.g., $foo['bar']['baz'] = 'qux').
25 *
26 * @param $offset
27 *
28 * @return mixed|null
29 */
30 #[\ReturnTypeWillChange]
31 public function & offsetGet($offset)
32 {
33 if (isset($this->data[$offset])) {
34 return $this->data[$offset];
35 }
36
37 $value = null;
38 return $value;
39 }
40
41 /**
42 * @return void
43 */
44 #[\ReturnTypeWillChange]
45 public function offsetSet($offset, $value)
46 {
47 $this->data[$offset] = $value;
48 }
49
50 /**
51 * @return bool
52 */
53 #[\ReturnTypeWillChange]
54 public function offsetExists($offset)
55 {
56 return isset($this->data[$offset]);
57 }
58
59 /**
60 * @return void
61 */
62 #[\ReturnTypeWillChange]
63 public function offsetUnset($offset)
64 {
65 unset($this->data[$offset]);
66 }
67
68 public function toArray()
69 {
70 return $this->data;
71 }
72
73 /**
74 * @return int
75 */
76 #[\ReturnTypeWillChange]
77 public function count()
78 {
79 return count($this->data);
80 }
81 }