Manager   A
last analyzed

Complexity

Total Complexity 5

Size/Duplication

Total Lines 24
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 1

Importance

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

3 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 4 2
A get() 0 8 2
A createProxy() 0 4 1
1
<?php
2
3
/*
4
 * This is part of the webuni/srazy-api-client.
5
 *
6
 * (c) Martin Hasoň <[email protected]>
7
 * (c) Webuni s.r.o. <[email protected]>
8
 *
9
 * For the full copyright and license information, please view the LICENSE
10
 * file that was distributed with this source code.
11
 */
12
13
namespace Webuni\Srazy;
14
15
use ProxyManager\Factory\LazyLoadingGhostFactory;
16
use ProxyManager\Factory\LazyLoadingValueHolderFactory;
17
18
class Manager
19
{
20
    private $factory;
21
    private $identityMap = [];
22
23
    public function __construct(LazyLoadingValueHolderFactory $factory = null)
24
    {
25
        $this->factory = $factory ?: new LazyLoadingGhostFactory();
26
    }
27
28
    public function get($class, $uri, $initializer)
29
    {
30
        if (!isset($this->identityMap[$class][$uri])) {
31
            $this->identityMap[$class][$uri] = $this->createProxy($class, $initializer);
32
        }
33
34
        return $this->identityMap[$class][$uri];
35
    }
36
37
    private function createProxy($type, $initializer)
38
    {
39
        return $this->factory->createProxy($type, $initializer);
40
    }
41
}
42