vendor/sulu/sulu/src/Sulu/Component/Content/Document/Structure/PropertyValue.php line 59

Open in your IDE?
  1. <?php
  2. /*
  3.  * This file is part of Sulu.
  4.  *
  5.  * (c) Sulu GmbH
  6.  *
  7.  * This source file is subject to the MIT license that is bundled
  8.  * with this source code in the file LICENSE.
  9.  */
  10. namespace Sulu\Component\Content\Document\Structure;
  11. /**
  12.  * Value object for content type rendering.
  13.  *
  14.  * Note this would more appropriately be named "Property" but that potentially confuses
  15.  * things even more whilst the Compat\\ namespace exists. In addition, this class may
  16.  * not be long lived after we change the content mapping logic.
  17.  */
  18. class PropertyValue implements \ArrayAccess
  19. {
  20.     private $value;
  21.     private $name;
  22.     public function __construct($name$value null)
  23.     {
  24.         $this->name $name;
  25.         $this->value $value;
  26.     }
  27.     public function getValue()
  28.     {
  29.         return $this->value;
  30.     }
  31.     public function setValue($value)
  32.     {
  33.         $this->value $value;
  34.     }
  35.     public function getName()
  36.     {
  37.         return $this->name;
  38.     }
  39.     public function setName($name)
  40.     {
  41.         $this->name $name;
  42.     }
  43.     #[\ReturnTypeWillChange]
  44.     public function offsetExists($offset)
  45.     {
  46.         return \is_array($this->value) && isset($this->value[$offset]);
  47.     }
  48.     public function offsetGet($offset)
  49.     {
  50.         if (!\is_array($this->value)) {
  51.             return;
  52.         }
  53.         return $this->value[$offset];
  54.     }
  55.     #[\ReturnTypeWillChange]
  56.     public function offsetSet($offset$value)
  57.     {
  58.         if (!\is_array($this->value)) {
  59.             return;
  60.         }
  61.         $this->value[$offset] = $value;
  62.     }
  63.     #[\ReturnTypeWillChange]
  64.     public function offsetUnset($offset)
  65.     {
  66.         if (!\is_array($this->value)) {
  67.             return;
  68.         }
  69.         unset($this->value[$offset]);
  70.     }
  71. }