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

LoaderFactory::create()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 9
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 6

Importance

Changes 0
Metric Value
dl 0
loc 9
ccs 0
cts 7
cp 0
rs 9.6666
c 0
b 0
f 0
cc 2
eloc 4
nc 2
nop 1
crap 6
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