GzipArchiveProcessorFactory::addConfiguration()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 9
Code Lines 6

Duplication

Lines 9
Ratio 100 %

Code Coverage

Tests 6
CRAP Score 1

Importance

Changes 0
Metric Value
dl 9
loc 9
ccs 6
cts 6
cp 1
rs 9.6666
c 0
b 0
f 0
cc 1
eloc 6
nc 1
nop 1
crap 1
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\GzipArchiveProcessor;
11
12
/**
13
 * @author Kevin Bond <[email protected]>
14
 */
15 View Code Duplication
class GzipArchiveProcessorFactory 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 'gzip';
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_gzip'))
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(GzipArchiveProcessor::DEFAULT_OPTIONS)->end()
50 5
                ->integerNode('timeout')->defaultValue(GzipArchiveProcessor::DEFAULT_TIMEOUT)->end()
51 5
            ->end()
52
        ;
53 5
    }
54
}
55