UploadVideoCommand::doExecuteCommand()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 15

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 9
CRAP Score 1

Importance

Changes 0
Metric Value
dl 0
loc 15
ccs 9
cts 9
cp 1
rs 9.7666
c 0
b 0
f 0
cc 1
nc 1
nop 2
crap 1
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 for upload video files into a Panda cloud.
21
 *
22
 * @author Christian Flothmann <[email protected]>
23
 */
24
final class UploadVideoCommand extends CloudCommand
25
{
26
    protected static $defaultName = 'panda:video:upload';
27
28
    /**
29
     * {@inheritDoc}
30
     */
31 8
    protected function configure()
32
    {
33 8
        $this->setDescription('Upload a video');
34 8
        $this->addOption(
35 8
            'profile',
36 8
            null,
37 8
            InputOption::VALUE_REQUIRED|InputOption::VALUE_IS_ARRAY,
38 8
            'A profile to be used to encode the video, use it several times to use more than one profile'
39
        );
40 8
        $this->addOption(
41 8
            'path-format',
42 8
            null,
43 8
            InputOption::VALUE_REQUIRED,
44 8
            'Custom path format'
45
        );
46 8
        $this->addOption(
47 8
            'payload',
48 8
            null,
49 8
            InputOption::VALUE_REQUIRED,
50 8
            'An arbitrary string stored with the video'
51
        );
52 8
        $this->addArgument(
53 8
            'filename',
54 8
            InputArgument::REQUIRED,
55 8
            'The file being uploaded'
56
        );
57
58 8
        parent::configure();
59 8
    }
60
61
    /**
62
     * {@inheritDoc}
63
     */
64 6
    protected function doExecuteCommand(InputInterface $input, OutputInterface $output)
65
    {
66 6
        $profiles = $input->getOption('profile');
67 6
        $pathFormat = $input->getOption('path-format');
68 6
        $payload = $input->getOption('payload');
69
70 6
        $output->writeln('Starting file upload...');
71 6
        $this->getCloud($input)->encodeVideoFile(
72 6
            $input->getArgument('filename'),
0 ignored issues
show
Bug introduced by
It seems like $input->getArgument('filename') targeting Symfony\Component\Consol...nterface::getArgument() can also be of type array<integer,string> or null; however, Xabbuh\PandaClient\Api\C...face::encodeVideoFile() 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...
73
            $profiles,
74
            $pathFormat,
75
            $payload
76
        );
77 5
        $output->writeln('<info>File uploaded successfully.</info>');
78 5
    }
79
}
80