You are here

abstract class Descriptor in Zircon Profile 8

Same name and namespace in other branches
  1. 8.0 vendor/symfony/console/Descriptor/Descriptor.php \Symfony\Component\Console\Descriptor\Descriptor

@author Jean-François Simon <jeanfrancois.simon@sensiolabs.com>

@internal

Hierarchy

Expanded class hierarchy of Descriptor

File

vendor/symfony/console/Descriptor/Descriptor.php, line 26

Namespace

Symfony\Component\Console\Descriptor
View source
abstract class Descriptor implements DescriptorInterface {

  /**
   * @var OutputInterface
   */
  private $output;

  /**
   * {@inheritdoc}
   */
  public function describe(OutputInterface $output, $object, array $options = array()) {
    $this->output = $output;
    switch (true) {
      case $object instanceof InputArgument:
        $this
          ->describeInputArgument($object, $options);
        break;
      case $object instanceof InputOption:
        $this
          ->describeInputOption($object, $options);
        break;
      case $object instanceof InputDefinition:
        $this
          ->describeInputDefinition($object, $options);
        break;
      case $object instanceof Command:
        $this
          ->describeCommand($object, $options);
        break;
      case $object instanceof Application:
        $this
          ->describeApplication($object, $options);
        break;
      default:
        throw new \InvalidArgumentException(sprintf('Object of type "%s" is not describable.', get_class($object)));
    }
  }

  /**
   * Writes content to output.
   *
   * @param string $content
   * @param bool   $decorated
   */
  protected function write($content, $decorated = false) {
    $this->output
      ->write($content, false, $decorated ? OutputInterface::OUTPUT_NORMAL : OutputInterface::OUTPUT_RAW);
  }

  /**
   * Describes an InputArgument instance.
   *
   * @param InputArgument $argument
   * @param array         $options
   *
   * @return string|mixed
   */
  protected abstract function describeInputArgument(InputArgument $argument, array $options = array());

  /**
   * Describes an InputOption instance.
   *
   * @param InputOption $option
   * @param array       $options
   *
   * @return string|mixed
   */
  protected abstract function describeInputOption(InputOption $option, array $options = array());

  /**
   * Describes an InputDefinition instance.
   *
   * @param InputDefinition $definition
   * @param array           $options
   *
   * @return string|mixed
   */
  protected abstract function describeInputDefinition(InputDefinition $definition, array $options = array());

  /**
   * Describes a Command instance.
   *
   * @param Command $command
   * @param array   $options
   *
   * @return string|mixed
   */
  protected abstract function describeCommand(Command $command, array $options = array());

  /**
   * Describes an Application instance.
   *
   * @param Application $application
   * @param array       $options
   *
   * @return string|mixed
   */
  protected abstract function describeApplication(Application $application, array $options = array());

}

Members

Namesort descending Modifiers Type Description Overrides
Descriptor::$output private property
Descriptor::describe public function Describes an InputArgument instance. Overrides DescriptorInterface::describe
Descriptor::describeApplication abstract protected function Describes an Application instance. 4
Descriptor::describeCommand abstract protected function Describes a Command instance. 4
Descriptor::describeInputArgument abstract protected function Describes an InputArgument instance. 4
Descriptor::describeInputDefinition abstract protected function Describes an InputDefinition instance. 4
Descriptor::describeInputOption abstract protected function Describes an InputOption instance. 4
Descriptor::write protected function Writes content to output.