Completed
Push — master ( d404ac...fc4cfb )
by Alexander
10:24 queued 07:21
created

SerializableImpl   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 26
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 0
Metric Value
wmc 3
lcom 0
cbo 0
dl 0
loc 26
rs 10
1
<?php
2
/*
3
 * Go! AOP framework
4
 *
5
 * @copyright Copyright 2012, Lisachenko Alexander <[email protected]>
6
 *
7
 * This source file is subject to the license that is bundled
8
 * with this source code in the file LICENSE.
9
 */
10
11
namespace Demo\Aspect\Introduce;
12
13
/**
14
 * Example class to test aspects
15
 */
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