SuffixNumberFileCommandBuilder::handler()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 4
rs 10
c 0
b 0
f 0
cc 1
eloc 2
nc 1
nop 0
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\SuffixNumberUploadFileCommand;
16
use BenGorFile\File\Application\Command\Upload\SuffixNumberUploadFileHandler;
17
use Symfony\Component\DependencyInjection\Definition;
18
19
/**
20
 * Suffix number upload file command builder.
21
 *
22
 * @author Beñat Espiña <[email protected]>
23
 */
24
class SuffixNumberFileCommandBuilder extends UploadFileCommandBuilder
25
{
26
    /**
27
     * {@inheritdoc}
28
     */
29
    public function build($file)
30
    {
31
        $this->register($file);
32
33
        $this->container->setAlias(
34
            $this->aliasDefinitionName($file),
35
            $this->definitionName($file)
36
        );
37
38
        return $this->container;
39
    }
40
41
    /**
42
     * {@inheritdoc}
43
     */
44
    public function register($file)
45
    {
46
        if ($this->configuration['upload_strategy'] !== 'suffix_number') {
47
            return parent::register($file);
48
        }
49
50
        $this->container->setDefinition(
51
            $this->definitionName($file),
52
            (new Definition(
53
                $this->handler(), [
54
                    $this->container->getDefinition(
55
                        'bengor.file.infrastructure.domain.model.' . $file . '_filesystem'
56
                    ),
57
                    $this->container->getDefinition(
58
                        'bengor.file.infrastructure.persistence.' . $file . '_repository'
59
                    ),
60
                    $this->container->getDefinition(
61
                        'bengor.file.infrastructure.persistence.' . $file . '_specification_factory'
62
                    ),
63
                    $this->container->getDefinition(
64
                        'bengor.file.infrastructure.domain.model.' . $file . '_factory'
65
                    ),
66
                ]
67
            ))->addTag(
68
                'bengor_file_' . $file . '_command_bus_handler', [
69
                    'handles' => $this->command(),
70
                ]
71
            )
72
        );
73
    }
74
75
    /**
76
     * Gets the FQCN of command.
77
     *
78
     * @return string
79
     */
80
    private function command()
0 ignored issues
show
Bug introduced by
Consider using a different method name as you override a private method of the parent class.

Overwriting private methods is generally fine as long as you also use private visibility. It might still be preferable for understandability to use a different method name.

Loading history...
81
    {
82
        return SuffixNumberUploadFileCommand::class;
83
    }
84
85
    /**
86
     * Gets the FQCN of command handler.
87
     *
88
     * @return string
89
     */
90
    private function handler()
0 ignored issues
show
Bug introduced by
Consider using a different method name as you override a private method of the parent class.

Overwriting private methods is generally fine as long as you also use private visibility. It might still be preferable for understandability to use a different method name.

Loading history...
91
    {
92
        return SuffixNumberUploadFileHandler::class;
93
    }
94
}
95