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