vendor/shopware/core/Framework/Struct/ArrayStruct.php line 5

Open in your IDE?
  1. <?php declare(strict_types=1);
  2. namespace Shopware\Core\Framework\Struct;
  3. class ArrayStruct extends Struct implements \ArrayAccess
  4. {
  5.     /**
  6.      * @var array
  7.      */
  8.     protected $data;
  9.     /**
  10.      * @var string|null
  11.      */
  12.     protected $apiAlias;
  13.     public function __construct(array $data = [], ?string $apiAlias null)
  14.     {
  15.         $this->data $data;
  16.         $this->apiAlias $apiAlias;
  17.     }
  18.     public function has(string $property): bool
  19.     {
  20.         return \array_key_exists($property$this->data);
  21.     }
  22.     /**
  23.      * @deprecated tag:v6.5.0 - return type will be changed to bool
  24.      */
  25.     #[\ReturnTypeWillChange]
  26.     public function offsetExists($offset)/* :bool */
  27.     {
  28.         return \array_key_exists($offset$this->data);
  29.     }
  30.     /**
  31.      * @deprecated tag:v6.5.0 - return type will be changed to mixed
  32.      */
  33.     #[\ReturnTypeWillChange]
  34.     public function offsetGet($offset)/* :mixed */
  35.     {
  36.         return $this->data[$offset] ?? null;
  37.     }
  38.     public function offsetSet($offset$value): void
  39.     {
  40.         $this->data[$offset] = $value;
  41.     }
  42.     public function offsetUnset($offset): void
  43.     {
  44.         unset($this->data[$offset]);
  45.     }
  46.     public function get(string $key)
  47.     {
  48.         return $this->offsetGet($key);
  49.     }
  50.     /**
  51.      * @param string|int $key
  52.      * @param array      $value
  53.      *
  54.      * @return array
  55.      */
  56.     public function set($key$value)
  57.     {
  58.         return $this->data[$key] = $value;
  59.     }
  60.     public function assign(array $options)
  61.     {
  62.         $this->data array_replace_recursive($this->data$options);
  63.         return $this;
  64.     }
  65.     public function all()
  66.     {
  67.         return $this->data;
  68.     }
  69.     public function jsonSerialize(): array
  70.     {
  71.         $jsonArray parent::jsonSerialize();
  72.         // The key-values pairs from the property $data are now serialized in the JSON property "data". But the
  73.         // key-value pairs from data should appear in the serialization as they were properties of the ArrayStruct
  74.         // itself. Therefore the key-values moved one level up.
  75.         unset($jsonArray['data']);
  76.         $data $this->data;
  77.         $this->convertDateTimePropertiesToJsonStringRepresentation($data);
  78.         return array_merge($jsonArray$data);
  79.     }
  80.     public function getApiAlias(): string
  81.     {
  82.         return $this->apiAlias ?? 'array_struct';
  83.     }
  84.     public function getVars(): array
  85.     {
  86.         return $this->data;
  87.     }
  88. }