Passed
Push — feature/0.7.0 ( f8dc8d...75a66b )
by Ryuichi
42:58
created

PropertyProxy::__get()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 2
eloc 1
nc 2
nop 1
dl 0
loc 3
rs 10
c 0
b 0
f 0
1
<?php
2
namespace WebStream\Util;
3
4
use WebStream\Container\Container;
5
6
/**
7
 * PropertyProxy
8
 * @author Ryuichi Tanaka
9
 * @since 2015/05/02
10
 * @version 0.7
11
 */
12
trait PropertyProxy
13
{
14
    /**
15
     * @var Container プロパティコンテナ
16
     */
17
    private $__propertyContainer;
18
19
    /**
20
     * overload setter
21
     */
22
    public function __set($name, $value)
23
    {
24
        if ($this->__propertyContainer === null) {
25
            $this->__propertyContainer = new Container(false);
26
        }
27
        $this->__propertyContainer->{$name} = $value;
28
    }
29
30
    /**
31
     * overload setter
32
     */
33
    public function __get($name)
34
    {
35
        return $this->__propertyContainer !== null ? $this->__propertyContainer->{$name} : null;
36
    }
37
38
    /**
39
     * overload isset
40
     */
41
    public function __isset($name)
42
    {
43
        return $__propertyContainer === null || $__propertyContainer->{$name} === null;
0 ignored issues
show
Comprehensibility Best Practice introduced by
The variable $__propertyContainer seems to be never defined.
Loading history...
44
    }
45
46
    /**
47
     * overload unset
48
     */
49
    public function __unset($name)
50
    {
51
        $this->__propertyContainer->remove($name);
52
    }
53
54
    /**
55
     * コンテナクリア
56
     */
57
    public function __clear()
58
    {
59
        $this->__propertyContainer = null;
60
    }
61
}
62