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

LazyLoadingPropertyTrait::__get()   A

Complexity

Conditions 3
Paths 3

Size

Total Lines 11
Code Lines 5

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 5
CRAP Score 3.0416

Importance

Changes 1
Bugs 0 Features 1
Metric Value
eloc 5
c 1
b 0
f 1
dl 0
loc 11
ccs 5
cts 6
cp 0.8333
rs 10
cc 3
nc 3
nop 1
crap 3.0416
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
}