ModifyProfileCommand   A
last analyzed

Complexity

Total Complexity 10

Size/Duplication

Total Lines 117
Duplicated Lines 0 %

Coupling/Cohesion

Dependencies 5

Test Coverage

Coverage 98.63%

Importance

Changes 0
Metric Value
wmc 10
cbo 5
dl 0
loc 117
ccs 72
cts 73
cp 0.9863
rs 10
c 0
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
B configure() 0 59 1
C doExecuteCommand() 0 46 9
1
<?php
2
3
/*
4
 * This file is part of the XabbuhPandaBundle package.
5
 *
6
 * (c) Christian Flothmann <[email protected]>
7
 *
8
 * For the full copyright and license information, please view the LICENSE
9
 * file that was distributed with this source code.
10
 */
11
12
namespace Xabbuh\PandaBundle\Command;
13
14
use Symfony\Component\Console\Input\InputArgument;
15
use Symfony\Component\Console\Input\InputInterface;
16
use Symfony\Component\Console\Input\InputOption;
17
use Symfony\Component\Console\Output\OutputInterface;
18
19
/**
20
 * Command to modify a profile.
21
 *
22
 * @author Christian Flothmann <[email protected]>
23
 */
24
final class ModifyProfileCommand extends CloudCommand
25
{
26
    protected static $defaultName = 'panda:profile:modify';
27
28
    /**
29
     * {@inheritDoc}
30
     */
31 7
    protected function configure()
32
    {
33 7
        $this->setDescription('Modify a profile');
34 7
        $this->addArgument(
35 7
            'profile-id',
36 7
            InputArgument::REQUIRED,
37 7
            'Id of the profile'
38
        );
39 7
        $this->addOption(
40 7
            'name',
41 7
            null,
42 7
            InputOption::VALUE_REQUIRED,
43 7
            'Machine-readable unique name'
44
        );
45 7
        $this->addOption(
46 7
            'title',
47 7
            null,
48 7
            InputOption::VALUE_REQUIRED,
49 7
            'Human-readable name'
50
        );
51 7
        $this->addOption(
52 7
            'extname',
53 7
            null,
54 7
            InputOption::VALUE_REQUIRED,
55 7
            'File extension'
56
        );
57 7
        $this->addOption(
58 7
            'width',
59 7
            null,
60 7
            InputOption::VALUE_REQUIRED,
61 7
            'Width in pixels'
62
        );
63 7
        $this->addOption(
64 7
            'height',
65 7
            null,
66 7
            InputOption::VALUE_REQUIRED,
67 7
            'Height in Pixels'
68
        );
69 7
        $this->addOption(
70 7
            'audio-bitrate',
71 7
            null,
72 7
            InputOption::VALUE_REQUIRED,
73 7
            'Audio bit rate'
74
        );
75 7
        $this->addOption(
76 7
            'video-bitrate',
77 7
            null,
78 7
            InputOption::VALUE_REQUIRED,
79 7
            'Video bit rate'
80
        );
81 7
        $this->addOption(
82 7
            'aspect-mode',
83 7
            null,
84 7
            InputOption::VALUE_REQUIRED,
85 7
            'Aspect mode'
86
        );
87
88 7
        parent::configure();
89 7
    }
90
91
    /**
92
     * {@inheritDoc}
93
     */
94 5
    protected function doExecuteCommand(InputInterface $input, OutputInterface $output)
95
    {
96 5
        $profile = $this->getCloud($input)
97 5
            ->getProfile($input->getArgument('profile-id'));
0 ignored issues
show
Bug introduced by
It seems like $input->getArgument('profile-id') targeting Symfony\Component\Consol...nterface::getArgument() can also be of type array<integer,string> or null; however, Xabbuh\PandaClient\Api\C...Interface::getProfile() does only seem to accept string, maybe add an additional type check?

This check looks at variables that are passed out again to other methods.

If the outgoing method call has stricter type requirements than the method itself, an issue is raised.

An additional type check may prevent trouble.

Loading history...
98
99 4
        if (null !== $input->getOption('name')) {
100 1
            $profile->setName($input->getOption('name'));
101
        }
102
103 4
        if (null !== $input->getOption('title')) {
104 1
            $profile->setTitle($input->getOption('title'));
105
        }
106
107 4
        if (null !== $input->getOption('extname')) {
108 1
            $profile->setExtname($input->getOption('extname'));
109
        }
110
111 4
        if (null !== $input->getOption('width')) {
112 1
            $profile->setWidth($input->getOption('width'));
113
        }
114
115 4
        if (null !== $input->getOption('height')) {
116 1
            $profile->setHeight($input->getOption('height'));
117
        }
118
119 4
        if (null !== $input->getOption('audio-bitrate')) {
120 1
            $profile->setAudioBitrate($input->getOption('audio-bitrate'));
121
        }
122
123 4
        if (null !== $input->getOption('video-bitrate')) {
124 1
            $profile->setVideoBitrate($input->getOption('video-bitrate'));
125
        }
126
127 4
        if (null !== $input->getOption('aspect-mode')) {
128 1
            $profile->setAspectMode($input->getOption('aspect-mode'));
129
        }
130
131 4
        $this->getCloud($input)->setProfile($profile);
132
133 3
        $output->writeln(
134
            sprintf(
135 3
                '<info>Successfully modified profile %s</info>',
136 3
                $profile->getName()
137
            )
138
        );
139 3
    }
140
}
141