1<?php 2 3declare(strict_types=1); 4 5namespace Metadata; 6 7/** 8 * Base class for property metadata. 9 * 10 * This class is intended to be extended to add your application specific 11 * properties, and flags. 12 * 13 * @author Johannes M. Schmitt <schmittjoh@gmail.com> 14 */ 15class PropertyMetadata implements \Serializable 16{ 17 /** 18 * @var string 19 */ 20 public $class; 21 22 /** 23 * @var string 24 */ 25 public $name; 26 27 public function __construct(string $class, string $name) 28 { 29 $this->class = $class; 30 $this->name = $name; 31 } 32 33 /** 34 * @phpcsSuppress SlevomatCodingStandard.TypeHints.TypeHintDeclaration.MissingParameterTypeHint 35 * @phpcsSuppress SlevomatCodingStandard.TypeHints.TypeHintDeclaration.MissingReturnTypeHint 36 * @phpcsSuppress SlevomatCodingStandard.TypeHints.TypeHintDeclaration.UselessReturnAnnotation 37 * 38 * @return string 39 */ 40 public function serialize() 41 { 42 return serialize([ 43 $this->class, 44 $this->name, 45 ]); 46 } 47 48 /** 49 * @phpcsSuppress SlevomatCodingStandard.TypeHints.TypeHintDeclaration.MissingParameterTypeHint 50 * @phpcsSuppress SlevomatCodingStandard.TypeHints.TypeHintDeclaration.MissingReturnTypeHint 51 * @phpcsSuppress SlevomatCodingStandard.TypeHints.TypeHintDeclaration.UselessReturnAnnotation 52 * 53 * @param string $str 54 * @return void 55 */ 56 public function unserialize($str) 57 { 58 list($this->class, $this->name) = unserialize($str); 59 } 60} 61