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

LoaderFactory::__construct()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

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