Completed
Push — master ( 0e9f9c...65c20f )
by Kyle
03:24
created

BPClone::__get()   B

Complexity

Conditions 5
Paths 6

Size

Total Lines 13
Code Lines 7

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 4
CRAP Score 8.125

Importance

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