1<?php 2 3declare(strict_types=1); 4 5namespace JMS\Serializer\Metadata; 6 7class StaticPropertyMetadata extends PropertyMetadata 8{ 9 /** 10 * @var mixed 11 */ 12 private $value; 13 14 /** 15 * StaticPropertyMetadata constructor. 16 * 17 * @param mixed $fieldValue 18 * @param array $groups 19 */ 20 public function __construct(string $className, string $fieldName, $fieldValue, array $groups = []) 21 { 22 $this->class = $className; 23 $this->name = $fieldName; 24 $this->serializedName = $fieldName; 25 $this->value = $fieldValue; 26 $this->readOnly = true; 27 $this->groups = $groups; 28 } 29 30 /** 31 * @return mixed 32 */ 33 public function getValue() 34 { 35 return $this->value; 36 } 37 38 public function setAccessor(string $type, ?string $getter = null, ?string $setter = null): void 39 { 40 } 41 42 /** 43 * {@inheritdoc} 44 */ 45 public function serialize() 46 { 47 return serialize([ 48 $this->value, 49 parent::serialize(), 50 ]); 51 } 52 53 /** 54 * {@inheritdoc} 55 */ 56 public function unserialize($str) 57 { 58 $parentStr = $this->unserializeProperties($str); 59 [$this->class, $this->name] = unserialize($parentStr); 60 } 61 62 protected function unserializeProperties(string $str): string 63 { 64 [ 65 $this->value, 66 $parentStr, 67 ] = unserialize($str); 68 return parent::unserializeProperties($parentStr); 69 } 70} 71