Completed
Push — master ( b5c840...3d5461 )
by Marcus
04:46
created

__construct()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4

Duplication

Lines 4
Ratio 100 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 0
Metric Value
dl 4
loc 4
c 0
b 0
f 0
ccs 0
cts 4
cp 0
rs 10
cc 1
nc 1
nop 1
crap 2
1
<?php
2
3
/**
4
 * TechDivision\Import\Serializers\AdditionalAttributeCsvSerializerFactory
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 2018 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\Serializers;
22
23
use Symfony\Component\DependencyInjection\ContainerInterface;
24
use TechDivision\Import\Configuration\CsvConfigurationInterface;
25
use TechDivision\Import\Utils\DependencyInjectionKeys;
26
27
/**
28
 * The factory implementation for CSV value serializer instances.
29
 *
30
 * @author    Tim Wagner <[email protected]>
31
 * @copyright 2018 TechDivision GmbH <[email protected]>
32
 * @license   http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
33
 * @link      https://github.com/techdivision/import
34
 * @link      http://www.techdivision.com
35
 */
36 View Code Duplication
class AdditionalAttributeCsvSerializerFactory implements ConfigurationAwareSerializerFactoryInterface
0 ignored issues
show
Duplication introduced by
This class seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
37
{
38
39
    /**
40
     * The DI container instance.
41
     *
42
     * @var \Symfony\Component\DependencyInjection\ContainerInterface
43
     */
44
    protected $container;
45
46
    /**
47
     * Initialize the factory with the DI container instance.
48
     *
49
     * @param \Symfony\Component\DependencyInjection\ContainerInterface $container The DI container instance
50
     */
51
    public function __construct(ContainerInterface $container)
52
    {
53
        $this->container = $container;
54
    }
55
56
    /**
57
     * Creates and returns the serializer instance.
58
     *
59
     * @param \TechDivision\Import\Configuration\CsvConfigurationInterface $configuration The CSV configuration
60
     *
61
     * @return \TechDivision\Import\Serializers\ConfigurationAwareSerializerInterface The serializer instance
62
     */
63
    public function createSerializer(CsvConfigurationInterface $configuration)
64
    {
65
66
        // load the serializer instance from the container and pass the configuration
67
        /** @var \TechDivision\Import\Serializers\ConfigurationAwareSerializerInterface $serializer */
68
        $serializer = $this->container->get(DependencyInjectionKeys::IMPORT_SERIALIZER_CSV_ADDITIONAL_ATTRIBUTE);
69
        $serializer->init($configuration);
70
71
        // return the serializer instance
72
        return $serializer;
73
    }
74
}
75