Completed
Push — master ( 4db4ad...088dbe )
by Oleksandr
13s
created

RecordDeploymentConsole   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 80
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
wmc 2
eloc 43
dl 0
loc 80
c 0
b 0
f 0
rs 10

2 Methods

Rating   Name   Duplication   Size   Complexity  
A configure() 0 35 1
A execute() 0 13 1
1
<?php
2
3
/**
4
 * MIT License
5
 * For full license information, please view the LICENSE file that was distributed with this source code.
6
 */
7
8
namespace SprykerEco\Zed\NewRelic\Communication\Console;
9
10
use Spryker\Zed\Kernel\Communication\Console\Console;
11
use Symfony\Component\Console\Input\InputArgument;
12
use Symfony\Component\Console\Input\InputInterface;
13
use Symfony\Component\Console\Output\OutputInterface;
14
15
/**
16
 * @method \SprykerEco\Zed\NewRelic\Business\NewRelicFacadeInterface getFacade()
17
 */
18
class RecordDeploymentConsole extends Console
19
{
20
    const COMMAND_NAME = 'newrelic:record-deployment';
21
    const DESCRIPTION = 'Send deployment notification to New Relic';
22
23
    const ARGUMENT_APPLICATION_NAME = 'app_name';
24
    const ARGUMENT_APPLICATION_NAME_DESCRIPTION = 'The name of the application in New Relic';
25
26
    const ARGUMENT_USER = 'user';
27
    const ARGUMENT_USER_DESCRIPTION = 'The name of the deployer';
28
29
    const ARGUMENT_REVISION = 'revision';
30
    const ARGUMENT_REVISION_DESCRIPTION = 'Revision number';
31
32
    const ARGUMENT_DESCRIPTION = 'description';
33
    const ARGUMENT_DESCRIPTION_DESCRIPTION = 'Deployment description';
34
35
    const ARGUMENT_CHANGELOG = 'changelog';
36
    const ARGUMENT_CHANGELOG_DESCRIPTION = 'Change log';
37
38
    /**
39
     * @return void
40
     */
41
    protected function configure(): void
42
    {
43
        parent::configure();
44
45
        $this->setName(self::COMMAND_NAME);
46
        $this->setDescription(self::DESCRIPTION);
47
48
        $this->addArgument(
49
            self::ARGUMENT_APPLICATION_NAME,
50
            InputArgument::REQUIRED,
51
            self::ARGUMENT_APPLICATION_NAME_DESCRIPTION
52
        );
53
54
        $this->addArgument(
55
            self::ARGUMENT_USER,
56
            InputArgument::OPTIONAL,
57
            self::ARGUMENT_USER_DESCRIPTION
58
        );
59
60
        $this->addArgument(
61
            self::ARGUMENT_REVISION,
62
            InputArgument::OPTIONAL,
63
            self::ARGUMENT_REVISION_DESCRIPTION
64
        );
65
66
        $this->addArgument(
67
            self::ARGUMENT_DESCRIPTION,
68
            InputArgument::OPTIONAL,
69
            self::ARGUMENT_DESCRIPTION_DESCRIPTION
70
        );
71
72
        $this->addArgument(
73
            self::ARGUMENT_CHANGELOG,
74
            InputArgument::OPTIONAL,
75
            self::ARGUMENT_CHANGELOG_DESCRIPTION
76
        );
77
    }
78
79
    /**
80
     * @param \Symfony\Component\Console\Input\InputInterface $input
81
     * @param \Symfony\Component\Console\Output\OutputInterface $output
82
     *
83
     * @return int
84
     */
85
    protected function execute(InputInterface $input, OutputInterface $output): int
86
    {
87
        $this->getMessenger()->info(sprintf(
88
            'Send deployment notification to New Relic for %s',
89
            $input->getArgument(self::ARGUMENT_APPLICATION_NAME)
0 ignored issues
show
Bug introduced by
It seems like $input->getArgument(self...UMENT_APPLICATION_NAME) can also be of type string[]; however, parameter $args of sprintf() does only seem to accept string, maybe add an additional type check? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-type  annotation

89
            /** @scrutinizer ignore-type */ $input->getArgument(self::ARGUMENT_APPLICATION_NAME)
Loading history...
90
        ));
91
92
        $arguments = $input->getArguments();
93
        unset($arguments['command']);
94
95
        $this->getFacade()->recordDeployment($arguments);
96
97
        return 0;
98
    }
99
}
100