Passed
Push — master ( e89c90...b07112 )
by Bas
03:34
created

LazyLoadingPropertyTrait   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 13
Duplicated Lines 0 %

Test Coverage

Coverage 83.33%

Importance

Changes 1
Bugs 0 Features 1
Metric Value
wmc 3
eloc 6
c 1
b 0
f 1
dl 0
loc 13
ccs 5
cts 6
cp 0.8333
rs 10

1 Method

Rating   Name   Duplication   Size   Complexity  
A __get() 0 11 3
1
<?php
2
0 ignored issues
show
Coding Style introduced by
Missing file doc comment
Loading history...
3
namespace DMT\Insolvency\Model;
4
5
trait LazyLoadingPropertyTrait
0 ignored issues
show
Coding Style introduced by
Missing doc comment for trait LazyLoadingPropertyTrait
Loading history...
6
{
7 7
    public function __get($key)
0 ignored issues
show
Coding Style introduced by
Missing doc comment for function __get()
Loading history...
8
    {
9 7
        if (!property_exists($this, $key)) {
10
            throw new \InvalidArgumentException(sprintf('%s does not exists on %s', $key, get_class($this)));
11
        }
12
13 7
        if ($this->$key instanceof \Closure) {
14 7
            $this->$key = call_user_func($this->$key);
15
        }
16
17 7
        return $this->$key;
18
    }
19
}