FactoryProxy::getInstance()   A
last analyzed

Complexity

Conditions 2
Paths 2

Size

Total Lines 7
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 7
rs 9.4285
c 0
b 0
f 0
cc 2
eloc 4
nc 2
nop 0
1
<?php namespace AdamWathan\Faktory\Factory;
2
3
class FactoryProxy
4
{
5
    protected $factory_loader;
6
    protected $instance;
7
8
    public function __construct($factory_loader)
9
    {
10
        $this->factory_loader = $factory_loader;
11
    }
12
13
    protected function getInstance()
14
    {
15
        if (! isset($this->instance)) {
16
            $this->instance = $this->factory_loader->__invoke();
17
        }
18
        return $this->instance;
19
    }
20
21
    public function __call($method, $parameters)
22
    {
23
        $instance = $this->getInstance();
24
        return call_user_func_array([$instance, $method], $parameters);
25
    }
26
}
27