Completed
Push — master ( 3bd4e2...776f46 )
by Jesse
04:06
created

Proxying::__load()   A

Complexity

Conditions 3
Paths 3

Size

Total Lines 13
Code Lines 7

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
eloc 7
dl 0
loc 13
rs 10
c 0
b 0
f 0
cc 3
nc 3
nop 0
1
<?php declare(strict_types=1);
2
3
namespace Stratadox\Proxy;
4
5
/**
6
 * Proxying behaviour.
7
 *
8
 * @author Stratadox
9
 */
10
trait Proxying
11
{
12
    /** @var null|static */
13
    private $instance;
14
    private $loader;
15
    private $knownData;
16
17
    public function __construct(ProxyLoader $loader, array $knownData)
18
    {
19
        $this->loader = $loader;
20
        $this->knownData = $knownData;
21
    }
22
23
    /** @return static */
24
    private function _load()
25
    {
26
        if (null === $this->instance) {
27
            $this->instance = $this->loader->loadTheInstance($this->knownData);
28
        }
29
        return $this->instance;
30
    }
31
}
32