Completed
Push — feature/EVO-7964_fundInfo-exte... ( d593d5 )
by Bastian
08:56
created

LoaderFactory   A

Complexity

Total Complexity 4

Size/Duplication

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