Completed
Push — master ( f9c2c5...1af469 )
by Kyle
39:40 queued 35:46
created

BPClone::__call()   A

Complexity

Conditions 3
Paths 4

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 3

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 4
ccs 2
cts 2
cp 1
rs 10
cc 3
eloc 2
nc 4
nop 2
crap 3
1
<?php
2
3
namespace BootPress\Theme;
4
5
class BPClone
6
{
7
    private $class;
8
    private $clone = array();
9
10 2
    public function __construct($class = null)
11
    {
12 2
        $this->class = $class;
13 2
    }
14
15 16
    public function __get($name)
16
    {
17 16
        $property = ($this->class) ? $this->class->$name : null;
18 16
        if (is_object($property) || is_null($property)) {
19 15
            if (!isset($this->clone[$name])) {
20 1
                $this->clone[$name] = new BPClone($property);
21 1
            }
22
            
23 15
            return $this->clone[$name];
24
        }
25
        
26 12
        return $property;
27
    }
28
29 19
    public function __call($name, $arguments)
30
    {
31 19
        return ($this->class && is_callable(array($this->class, $name))) ? call_user_func_array(array($this->class, $name), $arguments) : null;
32
    }
33
}
34