Proxy::__set()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 4

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 0
Metric Value
cc 1
nc 1
nop 2
dl 0
loc 4
ccs 0
cts 3
cp 0
crap 2
rs 10
c 0
b 0
f 0
1
<?php
2
3
namespace arc\traits;
4
5
trait Proxy
6
{
7
    protected $target;
8
9
    public function __construct($target)
10
    {
11
        $this->target = $target;
12
    }
13
14
    public function __get($name)
15
    {
16
        return $this->target->$name;
17
    }
18
19
    public function __set($name, $value)
20
    {
21
        $this->target->{$name} = $value;
22
    }
23
24
    public function __isset($name)
25
    {
26
        return isset( $this->target->$name );
27
    }
28
29
    public function __clone()
30
    {
31
        if (is_object( $this->target )) {
32
            $this->target = clone $this->target;
33
        }
34
    }
35
36
    public function __call($name, $args)
37
    {
38
        return call_user_func_array( [ $this->target, $name ], $args );
39
    }
40
41
    public function __toString()
42
    {
43
        return (string) $this->target;
44
    }
45
}
46