Proxy   A
last analyzed

Complexity

Total Complexity 8

Size/Duplication

Total Lines 41
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 0

Test Coverage

Coverage 0%

Importance

Changes 0
Metric Value
dl 0
loc 41
ccs 0
cts 18
cp 0
rs 10
c 0
b 0
f 0
wmc 8
lcom 0
cbo 0

7 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 4 1
A __get() 0 4 1
A __set() 0 4 1
A __isset() 0 4 1
A __call() 0 4 1
A __toString() 0 4 1
A __clone() 0 6 2
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