Proxying::_load()   A
last analyzed

Complexity

Conditions 2
Paths 2

Size

Total Lines 6
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 2
eloc 3
c 1
b 0
f 0
nc 2
nop 0
dl 0
loc 6
rs 10
1
<?php declare(strict_types=1);
2
3
namespace Stratadox\Proxy;
4
5
/**
6
 * Proxying behaviour. Basic behaviour for easily creating a proxy class.
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