Completed
Push — 8.x ( 824af6 )
by Tim
09:11
created

FileResolverFactory   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 38
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 3

Test Coverage

Coverage 0%

Importance

Changes 0
Metric Value
wmc 2
lcom 0
cbo 3
dl 0
loc 38
c 0
b 0
f 0
ccs 0
cts 10
cp 0
rs 10

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 4 1
A createFileResolver() 0 10 1
1
<?php
2
3
/**
4
 * TechDivision\Import\Subjects\FileResolver\FileResolverFactory
5
 *
6
 * NOTICE OF LICENSE
7
 *
8
 * This source file is subject to the Open Software License (OSL 3.0)
9
 * that is available through the world-wide-web at this URL:
10
 * http://opensource.org/licenses/osl-3.0.php
11
 *
12
 * PHP version 5
13
 *
14
 * @author    Tim Wagner <[email protected]>
15
 * @copyright 2016 TechDivision GmbH <[email protected]>
16
 * @license   http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
17
 * @link      https://github.com/techdivision/import
18
 * @link      http://www.techdivision.com
19
 */
20
21
namespace TechDivision\Import\Subjects\FileResolver;
22
23
use Symfony\Component\DependencyInjection\ContainerInterface;
24
use TechDivision\Import\Configuration\SubjectConfigurationInterface;
25
26
/**
27
 * Factory for file resolver instances.
28
 *
29
 * @author    Tim Wagner <[email protected]>
30
 * @copyright 2016 TechDivision GmbH <[email protected]>
31
 * @license   http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
32
 * @link      https://github.com/techdivision/import
33
 * @link      http://www.techdivision.com
34
 */
35
class FileResolverFactory implements FileResolverFactoryInterface
36
{
37
38
    /**
39
     * The DI container instance.
40
     *
41
     * @var \Symfony\Component\DependencyInjection\ContainerInterface
42
     */
43
    protected $container;
44
45
    /**
46
     * Initialize the factory with the DI container instance.
47
     *
48
     * @param \Symfony\Component\DependencyInjection\ContainerInterface $container The DI container instance
49
     */
50
    public function __construct(ContainerInterface $container)
51
    {
52
        $this->container = $container;
53
    }
54
55
    /**
56
     * Creates and returns the file resolver instance for the subject with the passed configuration.
57
     *
58
     * @param \TechDivision\Import\Configuration\SubjectConfigurationInterface $subject The subject to create the file resolver for
59
     *
60
     * @return \TechDivision\Import\Subjects\FileResolver\FileResolverInterface The file resolver instance
61
     */
62
    public function createFileResolver(SubjectConfigurationInterface $subject)
63
    {
64
65
        // create a new file resolver instance for the subject with the passed configuration
66
        $fileResolver = $this->container->get($subject->getFileResolver()->getId());
67
        $fileResolver->setSubjectConfiguration($subject);
68
69
        // return the file resolver instance
70
        return $fileResolver;
71
    }
72
}
73