Completed
Push — master ( 2b9e5a...666597 )
by Tim
17s queued 11s
created

CategoryCsvSerializerFactory   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 39
Duplicated Lines 100 %

Coupling/Cohesion

Components 0
Dependencies 1

Importance

Changes 0
Metric Value
wmc 2
lcom 0
cbo 1
dl 39
loc 39
rs 10
c 0
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 4 4 1
A createSerializer() 11 11 1

How to fix   Duplicated Code   

Duplicated Code

Duplicate code is one of the most pungent code smells. A rule that is often used is to re-structure code once it is duplicated in three or more places.

Common duplication problems, and corresponding solutions are:

1
<?php
2
3
/**
4
 * TechDivision\Import\Serializers\CategoryCsvSerializerFactory.php
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 2021 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\Utils\DependencyInjectionKeys;
25
use TechDivision\Import\Serializer\SerializerFactoryInterface;
26
use TechDivision\Import\Serializer\Configuration\SerializerConfigurationInterface;
27
28
/**
29
 * The factory implementation for category CSV serializer instances.
30
 *
31
 * @author    Tim Wagner <[email protected]>
32
 * @copyright 2021 TechDivision GmbH <[email protected]>
33
 * @license   http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
34
 * @link      https://github.com/techdivision/import
35
 * @link      http://www.techdivision.com
36
 */
37 View Code Duplication
class CategoryCsvSerializerFactory implements SerializerFactoryInterface
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...
38
{
39
40
    /**
41
     * The DI container instance.
42
     *
43
     * @var \Symfony\Component\DependencyInjection\ContainerInterface
44
     */
45
    protected $container;
46
47
    /**
48
     * Initialize the factory with the DI container instance.
49
     *
50
     * @param \Symfony\Component\DependencyInjection\ContainerInterface $container The DI container instance
51
     */
52
    public function __construct(ContainerInterface $container)
53
    {
54
        $this->container = $container;
55
    }
56
57
    /**
58
     * Creates and returns the serializer instance.
59
     *
60
     * @param \TechDivision\Import\Serializer\Configuration\SerializerConfigurationInterface $serializerConfiguration The serializer configuration
61
     *
62
     * @return \TechDivision\Import\Serializer\ConfigurationAwareSerializerInterface The serializer instance
63
     */
64
    public function createSerializer(SerializerConfigurationInterface $serializerConfiguration)
65
    {
66
67
        // load the serializer instance from the container and pass the configuration
68
        /** @var \TechDivision\Import\Serializer\SerializerInterface $serializer */
69
        $serializer = $this->container->get(DependencyInjectionKeys::IMPORT_SERIALIZER_CSV_CATEGORY);
70
        $serializer->init($serializerConfiguration);
71
72
        // return the serializer instance
73
        return $serializer;
74
    }
75
}
76