FactoryProxy   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 24
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 0

Importance

Changes 0
Metric Value
wmc 4
lcom 1
cbo 0
dl 0
loc 24
rs 10
c 0
b 0
f 0

3 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 4 1
A getInstance() 0 7 2
A __call() 0 5 1
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