Completed
Push — master ( 57370a...f21c17 )
by Kamil
9s
created

DefaultLoaderFactory::createLoader()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 10
Code Lines 6

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 10
rs 9.4285
cc 1
eloc 6
nc 1
nop 2
1
<?php
2
3
/*
4
 * This file is part of the ServiceContainerExtension package.
5
 *
6
 * (c) FriendsOfBehat
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 FriendsOfBehat\ServiceContainerExtension\ServiceContainer;
13
14
use Symfony\Component\Config\FileLocator;
15
use Symfony\Component\Config\Loader\DelegatingLoader;
16
use Symfony\Component\Config\Loader\LoaderResolver;
17
use Symfony\Component\DependencyInjection\ContainerBuilder;
18
use Symfony\Component\DependencyInjection\Loader\PhpFileLoader;
19
use Symfony\Component\DependencyInjection\Loader\XmlFileLoader;
20
use Symfony\Component\DependencyInjection\Loader\YamlFileLoader;
21
22
/**
23
 * @author Kamil Kokot <[email protected]>
24
 */
25
final class DefaultLoaderFactory implements LoaderFactory
26
{
27
    /**
28
     * {@inheritdoc}
29
     */
30
    public function createLoader(ContainerBuilder $container, array $config)
31
    {
32
        $fileLocator = new FileLocator($container->getParameter('paths.base'));
33
34
        return new DelegatingLoader(new LoaderResolver([
35
            new XmlFileLoader($container, $fileLocator),
36
            new YamlFileLoader($container, $fileLocator),
37
            new PhpFileLoader($container, $fileLocator),
38
        ]));
39
    }
40
}
41