Completed
Pull Request — develop (#512)
by Bastian
16:54 queued 09:51
created

LoaderFactory   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 44
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 1

Test Coverage

Coverage 0%

Importance

Changes 0
Metric Value
wmc 4
lcom 1
cbo 1
dl 0
loc 44
ccs 0
cts 15
cp 0
rs 10
c 0
b 0
f 0

3 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 4 1
A getLoaderDefinitions() 0 4 1
A create() 0 8 2
1
<?php
2
3
namespace Graviton\ProxyBundle\Definition\Loader;
4
5
use Graviton\ProxyBundle\Exception\LoaderException;
6
7
/**
8
 * Class LoaderFactory
9
 *
10
 * @package Graviton\ProxyBundle\Definition\Loader
11
 */
12
class LoaderFactory
13
{
14
    /** @var array  */
15
    private $loader;
16
17
18
    /**
19
     * LoaderFactory constructor.
20
     *
21
     * @param array $loader
22
     */
23
    public function __construct(array $loader)
24
    {
25
        $this->loader = $loader;
26
    }
27
28
    /**
29
     * Provides a list of registered loaders
30
     *
31
     * @return array
32
     */
33
    public function getLoaderDefinitions()
34
    {
35
        return $this->loader;
36
    }
37
38
    /**
39
     * Provides
40
     *
41
     * @param string $source
42
     *
43
     * @return LoaderInterface
44
     *
45
     * @throws LoaderException
46
     */
47
    public function create($source)
48
    {
49
        if (array_key_exists($source, $this->loader)) {
50
            return $this->loader[$source];
51
        }
52
53
        throw new LoaderException('Expected Loader for source ('. $source .') does not exist.');
54
    }
55
}
56