1 | <?php |
||
16 | trait SerializableImpl |
||
17 | { |
||
18 | /** |
||
19 | * String representation of object |
||
20 | * @return string the string representation of the object or null |
||
21 | */ |
||
22 | public function serialize() |
||
23 | { |
||
24 | return serialize(get_object_vars($this)); |
||
25 | } |
||
26 | |||
27 | /** |
||
28 | * Constructs the object |
||
29 | * @param string $serialized <p> |
||
30 | * The string representation of the object. |
||
31 | * </p> |
||
32 | * @return mixed the original value unserialized. |
||
33 | */ |
||
34 | public function unserialize($serialized) |
||
35 | { |
||
36 | $data = unserialize($serialized); |
||
37 | foreach ($data as $key=>$value) { |
||
38 | $this->$key = $value; |
||
39 | } |
||
40 | } |
||
41 | } |
||
42 |