MySqlDumpSourceFactory   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 52
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 8

Test Coverage

Coverage 100%

Importance

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

3 Methods

Rating   Name   Duplication   Size   Complexity  
A getName() 0 4 1
A create() 0 19 1
A addConfiguration() 0 15 1
1
<?php
2
3
namespace Zenstruck\BackupBundle\DependencyInjection\Factory\Source;
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\Source\MySqlDumpSource;
11
12
/**
13
 * @author Kevin Bond <[email protected]>
14
 */
15
class MySqlDumpSourceFactory implements Factory
16
{
17
    /**
18
     * {@inheritdoc}
19
     */
20 5
    public function getName()
21
    {
22 5
        return 'mysqldump';
23
    }
24
25
    /**
26
     * {@inheritdoc}
27
     */
28 1
    public function create(ContainerBuilder $container, $id, array $config)
29
    {
30 1
        $serviceId = sprintf('zenstruck_backup.source.%s', $id);
31
32 1
        $container->setDefinition($serviceId, new DefinitionDecorator('zenstruck_backup.source.abstract_mysqldump'))
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['database'])
35 1
            ->replaceArgument(2, $config['host'])
36 1
            ->replaceArgument(3, $config['user'])
37 1
            ->replaceArgument(4, $config['password'])
38 1
            ->replaceArgument(5, $config['ssh_host'])
39 1
            ->replaceArgument(6, $config['ssh_user'])
40 1
            ->replaceArgument(7, $config['ssh_port'])
41 1
            ->replaceArgument(8, $config['timeout'])
42 1
            ->addTag('zenstruck_backup.source')
43
        ;
44
45 1
        return new Reference($serviceId);
46
    }
47
48
    /**
49
     * {@inheritdoc}
50
     */
51 5
    public function addConfiguration(ArrayNodeDefinition $builder)
52
    {
53
        $builder
54 5
            ->children()
55 5
                ->scalarNode('database')->isRequired()->end()
56 5
                ->scalarNode('host')->defaultNull()->end()
57 5
                ->scalarNode('user')->defaultValue(MySqlDumpSource::DEFAULT_USER)->end()
58 5
                ->scalarNode('password')->defaultNull()->end()
59 5
                ->scalarNode('ssh_host')->defaultNull()->end()
60 5
                ->scalarNode('ssh_user')->defaultNull()->end()
61 5
                ->scalarNode('ssh_port')->defaultValue(MySqlDumpSource::DEFAULT_SSH_PORT)->end()
62 5
                ->integerNode('timeout')->defaultValue(MySqlDumpSource::DEFAULT_TIMEOUT)->end()
63 5
            ->end()
64
        ;
65 5
    }
66
}
67