vendor/shopware/core/Framework/Struct/AssignArrayTrait.php line 25

Open in your IDE?
  1. <?php declare(strict_types=1);
  2. namespace Shopware\Core\Framework\Struct;
  3. use Shopware\Core\Framework\Log\Package;
  4. #[Package('core')]
  5. trait AssignArrayTrait
  6. {
  7.     /**
  8.      * @param array<mixed> $options
  9.      *
  10.      * @return $this
  11.      */
  12.     public function assign(array $options)
  13.     {
  14.         foreach ($options as $key => $value) {
  15.             if ($key === 'id' && method_exists($this'setId')) {
  16.                 $this->setId($value);
  17.                 continue;
  18.             }
  19.             try {
  20.                 $this->$key $value;
  21.             } catch (\Error \Exception $error) {
  22.                 // nth
  23.             }
  24.         }
  25.         return $this;
  26.     }
  27. }