ZipArchiveProcessorFactory   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 40
Duplicated Lines 100 %

Coupling/Cohesion

Components 0
Dependencies 8

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
wmc 3
lcom 0
cbo 8
dl 40
loc 40
ccs 16
cts 16
cp 1
rs 10
c 0
b 0
f 0

3 Methods

Rating   Name   Duplication   Size   Complexity  
A getName() 4 4 1
A create() 13 13 1
A addConfiguration() 9 9 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
namespace Zenstruck\BackupBundle\DependencyInjection\Factory\Processor;
4
5
use Symfony\Component\Config\Definition\Builder\ArrayNodeDefinition;
6
use Symfony\Component\DependencyInjection\ContainerBuilder;
7
use Symfony\Component\DependencyInjection\DefinitionDecorator;
8
use Symfony\Component\DependencyInjection\Reference;
9
use Zenstruck\BackupBundle\DependencyInjection\Factory\Factory;
10
use Zenstruck\Backup\Processor\ZipArchiveProcessor;
11
12
/**
13
 * @author Kevin Bond <[email protected]>
14
 */
15 View Code Duplication
class ZipArchiveProcessorFactory implements Factory
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...
16
{
17
    /**
18
     * {@inheritdoc}
19
     */
20 5
    public function getName()
21
    {
22 5
        return 'zip';
23
    }
24
25
    /**
26
     * {@inheritdoc}
27
     */
28 1
    public function create(ContainerBuilder $container, $id, array $config)
29
    {
30 1
        $serviceId = sprintf('zenstruck_backup.processor.%s', $id);
31
32 1
        $container->setDefinition($serviceId, new DefinitionDecorator('zenstruck_backup.processor.abstract_zip'))
0 ignored issues
show
Deprecated Code introduced by
The class Symfony\Component\Depend...ion\DefinitionDecorator has been deprecated with message: The DefinitionDecorator class is deprecated since version 3.3 and will be removed in 4.0. Use the Symfony\Component\DependencyInjection\ChildDefinition class instead.

This class, trait or interface has been deprecated. The supplier of the file has supplied an explanatory message.

The explanatory message should give you some clue as to whether and when the type will be removed from the class and what other constant to use instead.

Loading history...
33 1
            ->replaceArgument(0, $id)
34 1
            ->replaceArgument(1, $config['options'])
35 1
            ->replaceArgument(2, $config['timeout'])
36 1
            ->addTag('zenstruck_backup.processor')
37
        ;
38
39 1
        return new Reference($serviceId);
40
    }
41
42
    /**
43
     * {@inheritdoc}
44
     */
45 5
    public function addConfiguration(ArrayNodeDefinition $builder)
46
    {
47
        $builder
48 5
            ->children()
49 5
                ->scalarNode('options')->defaultValue(ZipArchiveProcessor::DEFAULT_OPTIONS)->end()
50 5
                ->integerNode('timeout')->defaultValue(ZipArchiveProcessor::DEFAULT_TIMEOUT)->end()
51 5
            ->end()
52
        ;
53 5
    }
54
}
55