EncodingInfoCommand   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 55
Duplicated Lines 0 %

Coupling/Cohesion

Dependencies 5

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
wmc 3
cbo 5
dl 0
loc 55
ccs 34
cts 34
cp 1
rs 10
c 0
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A configure() 0 11 1
A doExecuteCommand() 0 32 2
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 an encoding's data.
21
 *
22
 * @author Christian Flothmann <[email protected]>
23
 */
24
final class EncodingInfoCommand extends CloudCommand
25
{
26
    protected static $defaultName = 'panda:encoding:info';
27
28
    /**
29
     * {@inheritDoc}
30
     */
31 5
    protected function configure()
32
    {
33 5
        $this->setDescription('Fetch information for an encoding');
34 5
        $this->addArgument(
35 5
            'encoding-id',
36 5
            InputArgument::REQUIRED,
37 5
            'The id of the encoding being fetched'
38
        );
39
40 5
        parent::configure();
41 5
    }
42
43
    /**
44
     * {@inheritDoc}
45
     */
46 3
    protected function doExecuteCommand(InputInterface $input, OutputInterface $output)
47
    {
48 3
        $cloud = $this->getCloud($input);
49 3
        $encoding = $cloud->getEncoding($input->getArgument('encoding-id'));
0 ignored issues
show
Bug introduced by
It seems like $input->getArgument('encoding-id') targeting Symfony\Component\Consol...nterface::getArgument() can also be of type array<integer,string> or null; however, Xabbuh\PandaClient\Api\C...nterface::getEncoding() 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 2
        $table = new Table($output);
51 2
        $table->addRows(array(
52 2
            array('id', $encoding->getId()),
53 2
            array('video id', $encoding->getVideoId()),
54 2
            array('file extension', $encoding->getExtname()),
55 2
            array('profile id', $encoding->getProfileId()),
56 2
            array('profile name', $encoding->getProfileName()),
57 2
            array('path', $encoding->getPath()),
58 2
            array('width', $encoding->getWidth()),
59 2
            array('height', $encoding->getHeight()),
60 2
            array('audio bit rate', $encoding->getAudioBitrate()),
61 2
            array('video bit rate', $encoding->getVideoBitrate()),
62 2
            array('status', $encoding->getStatus()),
63
        ));
64
65 2
        if ('fail' === $encoding->getStatus()) {
66 1
            $table->addRow(array('error message', $encoding->getErrorMessage()));
67
        }
68
69 2
        $table->addRows(array(
70 2
            array('encoding progress', $encoding->getEncodingProgress()),
71 2
            array('encoding started', $encoding->getStartedEncodingAt()),
72 2
            array('encoding time', $encoding->getEncodingTime()),
73 2
            array('created at', $encoding->getCreatedAt()),
74 2
            array('updated at', $encoding->getUpdatedAt()),
75
        ));
76 2
        $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...
77 2
    }
78
}
79