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 data of a video. |
21
|
|
|
* |
22
|
|
|
* @author Christian Flothmann <[email protected]> |
23
|
|
|
*/ |
24
|
|
|
final class VideoInfoCommand extends CloudCommand |
25
|
|
|
{ |
26
|
|
|
protected static $defaultName = 'panda:video:info'; |
27
|
|
|
|
28
|
|
|
/** |
29
|
|
|
* {@inheritDoc} |
30
|
|
|
*/ |
31
|
5 |
|
protected function configure() |
32
|
|
|
{ |
33
|
5 |
|
$this->setDescription('Fetch information for a video'); |
34
|
5 |
|
$this->addArgument( |
35
|
5 |
|
'video-id', |
36
|
5 |
|
InputArgument::REQUIRED, |
37
|
5 |
|
'The id of the video 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 |
|
$video = $cloud->getVideo($input->getArgument('video-id')); |
|
|
|
|
50
|
|
|
|
51
|
2 |
|
$table = new Table($output); |
52
|
2 |
|
$table->addRows(array( |
53
|
2 |
|
array('id', $video->getId()), |
54
|
2 |
|
array('file name', $video->getOriginalFilename()), |
55
|
2 |
|
array('path', $video->getPath()), |
56
|
2 |
|
array('width', $video->getWidth()), |
57
|
2 |
|
array('height', $video->getHeight()), |
58
|
2 |
|
array('audio bit rate', $video->getAudioBitrate()), |
59
|
2 |
|
array('video bit rate', $video->getVideoBitrate()), |
60
|
2 |
|
array('status', $video->getStatus()), |
61
|
2 |
|
array('payload', $video->getPayload()), |
62
|
|
|
)); |
63
|
|
|
|
64
|
2 |
|
if ('fail' === $video->getStatus()) { |
65
|
1 |
|
$table->addRow(array('error message', $video->getErrorMessage())); |
66
|
|
|
} |
67
|
|
|
|
68
|
2 |
|
$table->addRows(array( |
69
|
2 |
|
array('created at', $video->getCreatedAt()), |
70
|
2 |
|
array('updated at', $video->getUpdatedAt()), |
71
|
|
|
)); |
72
|
2 |
|
$table->render($output); |
|
|
|
|
73
|
2 |
|
} |
74
|
|
|
} |
75
|
|
|
|
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.