FactoryProxy::__call()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 5
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 5
rs 9.4285
c 0
b 0
f 0
cc 1
eloc 3
nc 1
nop 2
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