Loader   A
last analyzed

Complexity

Total Complexity 6

Size/Duplication

Total Lines 78
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 0

Test Coverage

Coverage 100%

Importance

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

6 Methods

Rating   Name   Duplication   Size   Complexity  
A load() 0 4 1
A getResolver() 0 4 1
A setResolver() 0 4 1
A addLoader() 0 6 1
A addLoaders() 0 8 2
loadFile() 0 1 ?
1
<?php
2
3
/*
4
 * This file is part of the ConfigCacheBundle package.
5
 *
6
 * Copyright (c) 2015-2016 Yahoo Japan Corporation
7
 *
8
 * For the full copyright and license information, please view the LICENSE
9
 * file that was distributed with this source code.
10
 */
11
12
namespace YahooJapan\ConfigCacheBundle\ConfigCache\Loader;
13
14
use Symfony\Component\Config\Loader\LoaderInterface;
15
use Symfony\Component\Config\Loader\LoaderResolverInterface;
16
17
/**
18
 * FileLoader is the abstract class used by loading configuration file.
19
 */
20
abstract class Loader implements LoaderInterface
21
{
22
    protected $resolver;
23
    protected $loaders = array();
24
25
    /**
26
     * Loads a resource.
27
     *
28
     * @SuppressWarnings(PHPMD.UnusedFormalParameter)
29
     * @param string $resource File name
30
     * @param string $type     The resource type
31
     *
32
     * @return array
33
     */
34 32
    public function load($resource, $type = null)
35
    {
36 32
        return $this->loadFile($resource);
37
    }
38
39
    /**
40
     * Gets the loader resolver.
41
     *
42
     * @return LoaderResolverInterface A LoaderResolverInterface instance
43
     */
44 1
    public function getResolver()
45
    {
46 1
        return $this->resolver;
47
    }
48
49
    /**
50
     * Sets the loader resolver.
51
     *
52
     * @param LoaderResolverInterface $resolver A LoaderResolverInterface instance
53
     */
54 11
    public function setResolver(LoaderResolverInterface $resolver)
55
    {
56 11
        $this->resolver = $resolver;
57 11
    }
58
59
    /**
60
     * Adds an array loader.
61
     *
62
     * @param ArrayLoaderInterface $loader
63
     *
64
     * @return Loader
65
     */
66 7
    public function addLoader(ArrayLoaderInterface $loader)
67
    {
68 7
        $this->loaders[] = $loader;
69
70 7
        return $this;
71
    }
72
73
    /**
74
     * Adds array loaders.
75
     *
76
     * @param array $loaders
77
     *
78
     * @return Loader
79
     */
80 2
    public function addLoaders(array $loaders)
81
    {
82 2
        foreach ($loaders as $loader) {
83 2
            $this->addLoader($loader);
84 2
        }
85
86 2
        return $this;
87
    }
88
89
    /**
90
     * Loads internal processing.
91
     *
92
     * @param string $file
93
     *
94
     * @return array|\SimpleXMLElement
95
     */
96
    abstract protected function loadFile($file);
97
}
98