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\InputInterface; |
16
|
|
|
use Symfony\Component\Console\Input\InputOption; |
17
|
|
|
use Symfony\Component\Console\Output\OutputInterface; |
18
|
|
|
|
19
|
|
|
/** |
20
|
|
|
* Command for displaying lists of encodings. |
21
|
|
|
* |
22
|
|
|
* @author Christian Flothmann <[email protected]> |
23
|
|
|
*/ |
24
|
|
|
final class ListEncodingsCommand extends CloudCommand |
25
|
|
|
{ |
26
|
|
|
protected static $defaultName = 'panda:encoding:list'; |
27
|
|
|
|
28
|
|
|
/** |
29
|
|
|
* {@inheritDoc} |
30
|
|
|
*/ |
31
|
7 |
|
protected function configure() |
32
|
|
|
{ |
33
|
7 |
|
$this->setDescription('Display a (optionally filtered) list of encodings'); |
34
|
7 |
|
$this->addOption( |
35
|
7 |
|
'status', |
36
|
7 |
|
null, |
37
|
7 |
|
InputOption::VALUE_REQUIRED, |
38
|
7 |
|
'Filter by status (one of \'success\', \'fail\' or \'processing\')' |
39
|
|
|
); |
40
|
7 |
|
$this->addOption( |
41
|
7 |
|
'profile-id', |
42
|
7 |
|
null, |
43
|
7 |
|
InputOption::VALUE_REQUIRED, |
44
|
7 |
|
'Filter by a profile id' |
45
|
|
|
); |
46
|
7 |
|
$this->addOption( |
47
|
7 |
|
'profile-name', |
48
|
7 |
|
null, |
49
|
7 |
|
InputOption::VALUE_REQUIRED, |
50
|
7 |
|
'Filter by a profile name' |
51
|
|
|
); |
52
|
7 |
|
$this->addOption( |
53
|
7 |
|
'video-id', |
54
|
7 |
|
null, |
55
|
7 |
|
InputOption::VALUE_REQUIRED, |
56
|
7 |
|
'Filter by video id' |
57
|
|
|
); |
58
|
|
|
|
59
|
7 |
|
parent::configure(); |
60
|
7 |
|
} |
61
|
|
|
|
62
|
|
|
/** |
63
|
|
|
* {@inheritDoc} |
64
|
|
|
*/ |
65
|
6 |
|
protected function doExecuteCommand(InputInterface $input, OutputInterface $output) |
66
|
|
|
{ |
67
|
6 |
|
$filter = array(); |
68
|
|
|
|
69
|
6 |
|
if (null !== $input->getOption('status')) { |
70
|
1 |
|
$filter['status'] = $input->getOption('status'); |
71
|
|
|
} |
72
|
|
|
|
73
|
6 |
|
if (null !== $input->getOption('profile-id')) { |
74
|
1 |
|
$filter['profile_id'] = $input->getOption('profile-id'); |
75
|
|
|
} |
76
|
|
|
|
77
|
6 |
|
if (null !== $input->getOption('profile-name')) { |
78
|
1 |
|
$filter['profile_name'] = $input->getOption('profile-name'); |
79
|
|
|
} |
80
|
|
|
|
81
|
6 |
|
if (null !== $input->getOption('video-id')) { |
82
|
1 |
|
$filter['video_id'] = $input->getOption('video-id'); |
83
|
|
|
} |
84
|
|
|
|
85
|
6 |
|
$encodings = $this->getCloud($input)->getEncodings($filter); |
86
|
|
|
|
87
|
5 |
|
if (count($encodings) > 0) { |
88
|
5 |
|
$table = new Table($output); |
89
|
5 |
|
$table->setHeaders(array( |
90
|
5 |
|
'encoding id', |
91
|
|
|
'video id', |
92
|
|
|
'profile id', |
93
|
|
|
'profile name', |
94
|
|
|
'encoding status', |
95
|
|
|
)); |
96
|
|
|
|
97
|
5 |
|
foreach ($encodings as $encoding) { |
98
|
5 |
|
if ($encoding->getStatus() == 'fail') { |
99
|
5 |
|
$status = sprintf( |
100
|
5 |
|
'fail (%s)', |
101
|
5 |
|
$encoding->getErrorMessage() |
102
|
|
|
); |
103
|
5 |
|
} elseif ($encoding->getStatus() == 'processing') { |
104
|
5 |
|
$status = sprintf( |
105
|
5 |
|
'processing (%d%%)', |
106
|
5 |
|
$encoding->getEncodingProgress() |
107
|
|
|
); |
108
|
|
|
} else { |
109
|
5 |
|
$status = 'success'; |
110
|
|
|
} |
111
|
|
|
|
112
|
5 |
|
$table->addRow(array( |
113
|
5 |
|
$encoding->getId(), |
114
|
5 |
|
$encoding->getVideoId(), |
115
|
5 |
|
$encoding->getProfileId(), |
116
|
5 |
|
$encoding->getProfileName(), |
117
|
5 |
|
$status, |
118
|
|
|
)); |
119
|
|
|
} |
120
|
|
|
|
121
|
5 |
|
$table->render($output); |
|
|
|
|
122
|
|
|
} |
123
|
5 |
|
} |
124
|
|
|
} |
125
|
|
|
|
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.