VideoMetadataCommand::doExecuteCommand()   A
last analyzed

Complexity

Conditions 3
Paths 2

Size

Total Lines 15

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 10
CRAP Score 3

Importance

Changes 0
Metric Value
dl 0
loc 15
ccs 10
cts 10
cp 1
rs 9.7666
c 0
b 0
f 0
cc 3
nc 2
nop 2
crap 3
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\Helper\Table;
15
use Symfony\Component\Console\Input\InputArgument;
16
use Symfony\Component\Console\Input\InputInterface;
17
use Symfony\Component\Console\Output\OutputInterface;
18
19
/**
20
 * Fetch and display metadata of a video.
21
 *
22
 * @author Christian Flothmann <[email protected]>
23
 */
24
final class VideoMetadataCommand extends CloudCommand
25
{
26
    protected static $defaultName = 'panda:video:metadata';
27
28
    /**
29
     * {@inheritDoc}
30
     */
31 4
    protected function configure()
32
    {
33 4
        $this->setDescription('Fetch metadata for a video');
34 4
        $this->addArgument(
35 4
            'video-id',
36 4
            InputArgument::REQUIRED,
37 4
            'The id of the video'
38
        );
39
40 4
        parent::configure();
41 4
    }
42
43
    /**
44
     * {@inheritDoc}
45
     */
46 2
    protected function doExecuteCommand(InputInterface $input, OutputInterface $output)
47
    {
48 2
        $cloud = $this->getCloud($input);
49 2
        $metadata = $cloud->getVideoMetadata($input->getArgument('video-id'));
0 ignored issues
show
Bug introduced by
It seems like $input->getArgument('video-id') targeting Symfony\Component\Consol...nterface::getArgument() can also be of type array<integer,string> or null; however, Xabbuh\PandaClient\Api\C...ace::getVideoMetadata() 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...
50 1
        $table = new Table($output);
51
52 1
        foreach ($metadata as $key => $value) {
53 1
            $table->addRow(array(
54 1
                $key,
55 1
                is_array($value) ? implode(', ', $value) : $value,
56
            ));
57
        }
58
59 1
        $table->render($output);
0 ignored issues
show
Unused Code introduced by
The call to Table::render() has too many arguments starting with $output.

This check compares calls to functions or methods with their respective definitions. If the call has more arguments than are defined, it raises an issue.

If a function is defined several times with a different number of parameters, the check may pick up the wrong definition and report false positives. One codebase where this has been known to happen is Wordpress.

In this case you can add the @ignore PhpDoc annotation to the duplicate definition and it will be ignored.

Loading history...
60 1
    }
61
}
62