Completed
Push — feature/EVO-7964_fundInfo-exte... ( 142d3d...cf9459 )
by Bastian
08:28 queued 08:21
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
 * LoaderFactory
4
 */
5
6
namespace Graviton\ProxyBundle\Definition\Loader;
7
8
use Graviton\ProxyBundle\Exception\LoaderException;
9
10
/**
11
 * Class LoaderFactory
12
 *
13
 * @package Graviton\ProxyBundle\Definition\Loader
14
 * @author   List of contributors <https://github.com/libgraviton/graviton/graphs/contributors>
15
 * @license  http://opensource.org/licenses/gpl-license.php GNU Public License
16
 * @link     http://swisscom.ch
17
 */
18
class LoaderFactory
19
{
20
    /** @var array  */
21
    private $loader;
22
23
24
    /**
25
     * LoaderFactory constructor.
26
     *
27
     * @param array $loader The set of definition loaders available.
28
     */
29
    public function __construct(array $loader)
30
    {
31
        $this->loader = $loader;
32
    }
33
34
    /**
35
     * Provides a list of registered loaders
36
     *
37
     * @return array
38
     */
39
    public function getLoaderDefinitions()
40
    {
41
        return $this->loader;
42
    }
43
44
    /**
45
     * Provides
46
     *
47
     * @param string $source Information of what loader to be initiated.
48
     *
49
     * @return LoaderInterface
50
     *
51
     * @throws LoaderException
52
     */
53
    public function create($source)
54
    {
55
        if (array_key_exists($source, $this->loader)) {
56
            return $this->loader[$source];
57
        }
58
59
        throw new LoaderException('Expected Loader for source ('. $source .') does not exist.');
60
    }
61
}
62