[ Index ]

PHP Cross Reference of phpBB-3.3.7-deutsch

title

Body

[close]

/vendor/symfony/console/Descriptor/ -> Descriptor.php (source)

   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  
  14  use Symfony\Component\Console\Application;
  15  use Symfony\Component\Console\Command\Command;
  16  use Symfony\Component\Console\Exception\InvalidArgumentException;
  17  use Symfony\Component\Console\Input\InputArgument;
  18  use Symfony\Component\Console\Input\InputDefinition;
  19  use Symfony\Component\Console\Input\InputOption;
  20  use Symfony\Component\Console\Output\OutputInterface;
  21  
  22  /**
  23   * @author Jean-Fran├žois Simon <jeanfrancois.simon@sensiolabs.com>
  24   *
  25   * @internal
  26   */
  27  abstract class Descriptor implements DescriptorInterface
  28  {
  29      /**
  30       * @var OutputInterface
  31       */
  32      protected $output;
  33  
  34      /**
  35       * {@inheritdoc}
  36       */
  37      public function describe(OutputInterface $output, $object, array $options = [])
  38      {
  39          $this->output = $output;
  40  
  41          switch (true) {
  42              case $object instanceof InputArgument:
  43                  $this->describeInputArgument($object, $options);
  44                  break;
  45              case $object instanceof InputOption:
  46                  $this->describeInputOption($object, $options);
  47                  break;
  48              case $object instanceof InputDefinition:
  49                  $this->describeInputDefinition($object, $options);
  50                  break;
  51              case $object instanceof Command:
  52                  $this->describeCommand($object, $options);
  53                  break;
  54              case $object instanceof Application:
  55                  $this->describeApplication($object, $options);
  56                  break;
  57              default:
  58                  throw new InvalidArgumentException(sprintf('Object of type "%s" is not describable.', \get_class($object)));
  59          }
  60      }
  61  
  62      /**
  63       * Writes content to output.
  64       *
  65       * @param string $content
  66       * @param bool   $decorated
  67       */
  68      protected function write($content, $decorated = false)
  69      {
  70          $this->output->write($content, false, $decorated ? OutputInterface::OUTPUT_NORMAL : OutputInterface::OUTPUT_RAW);
  71      }
  72  
  73      /**
  74       * Describes an InputArgument instance.
  75       *
  76       * @return string|mixed
  77       */
  78      abstract protected function describeInputArgument(InputArgument $argument, array $options = []);
  79  
  80      /**
  81       * Describes an InputOption instance.
  82       *
  83       * @return string|mixed
  84       */
  85      abstract protected function describeInputOption(InputOption $option, array $options = []);
  86  
  87      /**
  88       * Describes an InputDefinition instance.
  89       *
  90       * @return string|mixed
  91       */
  92      abstract protected function describeInputDefinition(InputDefinition $definition, array $options = []);
  93  
  94      /**
  95       * Describes a Command instance.
  96       *
  97       * @return string|mixed
  98       */
  99      abstract protected function describeCommand(Command $command, array $options = []);
 100  
 101      /**
 102       * Describes an Application instance.
 103       *
 104       * @return string|mixed
 105       */
 106      abstract protected function describeApplication(Application $application, array $options = []);
 107  }


Generated: Thu Mar 24 21:31:15 2022 Cross-referenced by PHPXref 0.7.1