-
-
Notifications
You must be signed in to change notification settings - Fork 634
/
Command.php
81 lines (71 loc) · 2.15 KB
/
Command.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
<?php
/**
* phpDocumentor
*
* PHP Version 5.3
*
* @author Mike van Riel <mike.vanriel@naenius.com>
* @copyright 2010-2018 Mike van Riel / Naenius. (http://www.naenius.com)
* @license http://www.opensource.org/licenses/mit-license.php MIT
* @link http://phpdoc.org
*/
namespace phpDocumentor\Command;
use Symfony\Bundle\FrameworkBundle\Command\ContainerAwareCommand as BaseCommand;
use Symfony\Component\Console\Helper\HelperSet;
use Symfony\Component\Console\Helper\ProgressHelper;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Output\OutputInterface;
/**
* Base command for phpDocumentor commands.
*
* Includes additional methods to forward the output to the logging events
* of phpDocumentor.
*/
class Command extends BaseCommand
{
/**
* Registers the current command.
*
* @param HelperSet $helperSet
*/
public function setHelperSet(HelperSet $helperSet)
{
parent::setHelperSet($helperSet);
//
// $this->getHelper('phpdocumentor_logger')->addOptions($this);
}
public function getService(string $name)
{
return $this->getContainer()->get($name);
}
/**
* Executes a callable piece of code and writes an entry to the log detailing how long it took.
*/
protected function writeTimedLog(OutputInterface $output, $message, $operation, array $arguments = array())
{
$output->write(sprintf('%-66.66s .. ', $message));
$timerStart = microtime(true);
call_user_func_array($operation, $arguments);
$output->writeln(sprintf('%8.3fs', microtime(true) - $timerStart));
}
public function getService(string $name)
{
return $this->getContainer()->get($name);
}
/**
* Returns the Progress bar helper.
*
* With this helper it is possible to display a progress bar and make it fill.
*
* @param InputInterface $input
*
* @return ProgressHelper
*/
protected function getProgressBar(InputInterface $input)
{
if (!$input->getOption('progressbar')) {
return null;
}
return $this->getHelperSet()->get('progress');
}
}