vendor/shopware/core/Framework/Struct/CreateFromTrait.php line 10

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 CreateFromTrait
  6. {
  7.     public static function createFrom(Struct $object)
  8.     {
  9.         try {
  10.             $self = (new \ReflectionClass(static::class))
  11.                 ->newInstanceWithoutConstructor();
  12.         } catch (\ReflectionException $exception) {
  13.             throw new \InvalidArgumentException($exception->getMessage());
  14.         }
  15.         foreach (get_object_vars($object) as $property => $value) {
  16.             $self->$property $value;
  17.         }
  18.         return $self;
  19.     }
  20. }