Completed
Push — master ( 2c026b...1dd487 )
by Beñat
05:32 queued 02:43
created

UploadFileCommandBuilder   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 45
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 3

Importance

Changes 1
Bugs 0 Features 1
Metric Value
wmc 3
c 1
b 0
f 1
lcom 0
cbo 3
dl 0
loc 45
rs 10

3 Methods

Rating   Name   Duplication   Size   Complexity  
A register() 0 23 1
A definitionName() 0 4 1
A aliasDefinitionName() 0 4 1
1
<?php
2
3
/*
4
 * This file is part of the BenGorFile package.
5
 *
6
 * (c) Beñat Espiña <[email protected]>
7
 * (c) Gorka Laucirica <[email protected]>
8
 *
9
 * For the full copyright and license information, please view the LICENSE
10
 * file that was distributed with this source code.
11
 */
12
13
namespace BenGorFile\FileBundle\DependencyInjection\Compiler\Application\Command;
14
15
use BenGorFile\File\Application\Command\Upload\UploadFileCommand;
16
use BenGorFile\File\Application\Command\Upload\UploadFileHandler;
17
use Symfony\Component\DependencyInjection\Definition;
18
19
/**
20
 * Upload file command builder.
21
 *
22
 * @author Beñat Espiña <[email protected]>
23
 */
24
class UploadFileCommandBuilder extends CommandBuilder
25
{
26
    /**
27
     * {@inheritdoc}
28
     */
29
    public function register($file)
30
    {
31
        $this->container->setDefinition(
32
            $this->definitionName($file),
33
            (new Definition(
34
                UploadFileHandler::class, [
35
                    $this->container->getDefinition(
36
                        'bengor.file.infrastructure.domain.model.gaufrette_filesystem_' . $file
37
                    ),
38
                    $this->container->getDefinition(
39
                        'bengor.file.infrastructure.persistence.' . $file . '_repository'
40
                    ),
41
                    $this->container->getDefinition(
42
                        'bengor.file.infrastructure.domain.model.' . $file . '_factory'
43
                    ),
44
                ]
45
            ))->addTag(
46
                'bengor_file_' . $file . '_command_bus_handler', [
47
                    'handles' => UploadFileCommand::class,
48
                ]
49
            )
50
        );
51
    }
52
53
    /**
54
     * {@inheritdoc}
55
     */
56
    protected function definitionName($file)
57
    {
58
        return 'bengor.file.application.command.upload_' . $file;
59
    }
60
61
    /**
62
     * {@inheritdoc}
63
     */
64
    protected function aliasDefinitionName($file)
65
    {
66
        return 'bengor_file.' . $file . '.upload';
67
    }
68
}
69