123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869 |
- <?php
-
-
-
- namespace Metadata;
-
-
- class PropertyMetadata implements \Serializable
- {
- public $class;
- public $name;
- public $reflection;
-
- public function __construct($class, $name)
- {
- $this->class = $class;
- $this->name = $name;
-
- $this->reflection = new \ReflectionProperty($class, $name);
- $this->reflection->setAccessible(true);
- }
-
- public function getValue($obj)
- {
- return $this->reflection->getValue($obj);
- }
-
- public function setValue($obj, $value)
- {
- $this->reflection->setValue($obj, $value);
- }
-
- public function serialize()
- {
- return serialize(array(
- $this->class,
- $this->name,
- ));
- }
-
- public function unserialize($str)
- {
- list($this->class, $this->name) = unserialize($str);
-
- $this->reflection = new \ReflectionProperty($this->class, $this->name);
- $this->reflection->setAccessible(true);
- }
- }
|