1 <?php 2 3 declare(strict_types=1); 4 5 namespace JMS\Serializer\Annotation; 6 7 use JMS\Serializer\Exception\InvalidArgumentException; 8 9 /** 10 * @Annotation 11 * @Target({"METHOD", "CLASS"}) 12 * 13 * @author Alexander Klimenkov <alx.devel@gmail.com> 14 */ 15 final class VirtualProperty 16 { 17 /** 18 * @var string 19 */ 20 public $exp; 21 22 /** 23 * @var string 24 */ 25 public $name; 26 27 /** 28 * @var array 29 */ 30 public $options = []; 31 32 public function __construct(array $data) 33 { 34 if (isset($data['value'])) { 35 $data['name'] = $data['value']; 36 unset($data['value']); 37 } 38 39 foreach ($data as $key => $value) { 40 if (!property_exists(self::class, $key)) { 41 throw new InvalidArgumentException(sprintf('Unknown property "%s" on annotation "%s".', $key, self::class)); 42 } 43 $this->{$key} = $value; 44 } 45 } 46 } 47