Completed
Pull Request — 1.x (#55)
by Christian
04:34 queued 03:27
created

ModifyProfileCommand   A

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 since 1.5
25
 */
26
class ModifyProfileCommand extends CloudCommand
27
{
28
    protected static $defaultName = 'panda:profile:modify';
29
30
    /**
31
     * {@inheritDoc}
32
     */
33 6
    protected function configure()
34
    {
35 6
        $this->setDescription('Modify a profile');
36 6
        $this->addArgument(
37 6
            'profile-id',
38 6
            InputArgument::REQUIRED,
39 6
            'Id of the profile'
40
        );
41 6
        $this->addOption(
42 6
            'name',
43 6
            null,
44 6
            InputOption::VALUE_REQUIRED,
45 6
            'Machine-readable unique name'
46
        );
47 6
        $this->addOption(
48 6
            'title',
49 6
            null,
50 6
            InputOption::VALUE_REQUIRED,
51 6
            'Human-readable name'
52
        );
53 6
        $this->addOption(
54 6
            'extname',
55 6
            null,
56 6
            InputOption::VALUE_REQUIRED,
57 6
            'File extension'
58
        );
59 6
        $this->addOption(
60 6
            'width',
61 6
            null,
62 6
            InputOption::VALUE_REQUIRED,
63 6
            'Width in pixels'
64
        );
65 6
        $this->addOption(
66 6
            'height',
67 6
            null,
68 6
            InputOption::VALUE_REQUIRED,
69 6
            'Height in Pixels'
70
        );
71 6
        $this->addOption(
72 6
            'audio-bitrate',
73 6
            null,
74 6
            InputOption::VALUE_REQUIRED,
75 6
            'Audio bit rate'
76
        );
77 6
        $this->addOption(
78 6
            'video-bitrate',
79 6
            null,
80 6
            InputOption::VALUE_REQUIRED,
81 6
            'Video bit rate'
82
        );
83 6
        $this->addOption(
84 6
            'aspect-mode',
85 6
            null,
86 6
            InputOption::VALUE_REQUIRED,
87 6
            'Aspect mode'
88
        );
89
90 6
        parent::configure();
91 6
    }
92
93
    /**
94
     * {@inheritDoc}
95
     */
96 5
    protected function doExecuteCommand(InputInterface $input, OutputInterface $output)
97
    {
98 5
        $profile = $this->getCloud($input)
99 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...
100
101 4
        if (null !== $input->getOption('name')) {
102 1
            $profile->setName($input->getOption('name'));
103
        }
104
105 4
        if (null !== $input->getOption('title')) {
106 1
            $profile->setTitle($input->getOption('title'));
107
        }
108
109 4
        if (null !== $input->getOption('extname')) {
110 1
            $profile->setExtname($input->getOption('extname'));
111
        }
112
113 4
        if (null !== $input->getOption('width')) {
114 1
            $profile->setWidth($input->getOption('width'));
115
        }
116
117 4
        if (null !== $input->getOption('height')) {
118 1
            $profile->setHeight($input->getOption('height'));
119
        }
120
121 4
        if (null !== $input->getOption('audio-bitrate')) {
122 1
            $profile->setAudioBitrate($input->getOption('audio-bitrate'));
123
        }
124
125 4
        if (null !== $input->getOption('video-bitrate')) {
126 1
            $profile->setVideoBitrate($input->getOption('video-bitrate'));
127
        }
128
129 4
        if (null !== $input->getOption('aspect-mode')) {
130 1
            $profile->setAspectMode($input->getOption('aspect-mode'));
131
        }
132
133 4
        $this->getCloud($input)->setProfile($profile);
134
135 3
        $output->writeln(
136
            sprintf(
137 3
                '<info>Successfully modified profile %s</info>',
138 3
                $profile->getName()
139
            )
140
        );
141 3
    }
142
}
143