TYPO3  7.6
Descriptor.php
Go to the documentation of this file.
1 <?php
2 
3 /*
4  * This file is part of the Symfony package.
5  *
6  * (c) Fabien Potencier <fabien@symfony.com>
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 Symfony\Component\Console\Descriptor;
13 
20 
26 abstract class Descriptor implements DescriptorInterface
27 {
31  private $output;
32 
36  public function describe(OutputInterface $output, $object, array $options = array())
37  {
38  $this->output = $output;
39 
40  switch (true) {
41  case $object instanceof InputArgument:
42  $this->describeInputArgument($object, $options);
43  break;
44  case $object instanceof InputOption:
45  $this->describeInputOption($object, $options);
46  break;
47  case $object instanceof InputDefinition:
48  $this->describeInputDefinition($object, $options);
49  break;
50  case $object instanceof Command:
51  $this->describeCommand($object, $options);
52  break;
53  case $object instanceof Application:
54  $this->describeApplication($object, $options);
55  break;
56  default:
57  throw new \InvalidArgumentException(sprintf('Object of type "%s" is not describable.', get_class($object)));
58  }
59  }
60 
67  protected function write($content, $decorated = false)
68  {
69  $this->output->write($content, false, $decorated ? OutputInterface::OUTPUT_NORMAL : OutputInterface::OUTPUT_RAW);
70  }
71 
80  abstract protected function describeInputArgument(InputArgument $argument, array $options = array());
81 
90  abstract protected function describeInputOption(InputOption $option, array $options = array());
91 
100  abstract protected function describeInputDefinition(InputDefinition $definition, array $options = array());
101 
110  abstract protected function describeCommand(Command $command, array $options = array());
111 
120  abstract protected function describeApplication(Application $application, array $options = array());
121 }