diff options
Diffstat (limited to 'vendor/symfony/console/Descriptor/Descriptor.php')
| -rw-r--r-- | vendor/symfony/console/Descriptor/Descriptor.php | 74 |
1 files changed, 74 insertions, 0 deletions
diff --git a/vendor/symfony/console/Descriptor/Descriptor.php b/vendor/symfony/console/Descriptor/Descriptor.php new file mode 100644 index 0000000..7b2509c --- /dev/null +++ b/vendor/symfony/console/Descriptor/Descriptor.php | |||
| @@ -0,0 +1,74 @@ | |||
| 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 | protected OutputInterface $output; | ||
| 30 | |||
| 31 | public function describe(OutputInterface $output, object $object, array $options = []): void | ||
| 32 | { | ||
| 33 | $this->output = $output; | ||
| 34 | |||
| 35 | match (true) { | ||
| 36 | $object instanceof InputArgument => $this->describeInputArgument($object, $options), | ||
| 37 | $object instanceof InputOption => $this->describeInputOption($object, $options), | ||
| 38 | $object instanceof InputDefinition => $this->describeInputDefinition($object, $options), | ||
| 39 | $object instanceof Command => $this->describeCommand($object, $options), | ||
| 40 | $object instanceof Application => $this->describeApplication($object, $options), | ||
| 41 | default => throw new InvalidArgumentException(sprintf('Object of type "%s" is not describable.', get_debug_type($object))), | ||
| 42 | }; | ||
| 43 | } | ||
| 44 | |||
| 45 | protected function write(string $content, bool $decorated = false): void | ||
| 46 | { | ||
| 47 | $this->output->write($content, false, $decorated ? OutputInterface::OUTPUT_NORMAL : OutputInterface::OUTPUT_RAW); | ||
| 48 | } | ||
| 49 | |||
| 50 | /** | ||
| 51 | * Describes an InputArgument instance. | ||
| 52 | */ | ||
| 53 | abstract protected function describeInputArgument(InputArgument $argument, array $options = []): void; | ||
| 54 | |||
| 55 | /** | ||
| 56 | * Describes an InputOption instance. | ||
| 57 | */ | ||
| 58 | abstract protected function describeInputOption(InputOption $option, array $options = []): void; | ||
| 59 | |||
| 60 | /** | ||
| 61 | * Describes an InputDefinition instance. | ||
| 62 | */ | ||
| 63 | abstract protected function describeInputDefinition(InputDefinition $definition, array $options = []): void; | ||
| 64 | |||
| 65 | /** | ||
| 66 | * Describes a Command instance. | ||
| 67 | */ | ||
| 68 | abstract protected function describeCommand(Command $command, array $options = []): void; | ||
| 69 | |||
| 70 | /** | ||
| 71 | * Describes an Application instance. | ||
| 72 | */ | ||
| 73 | abstract protected function describeApplication(Application $application, array $options = []): void; | ||
| 74 | } | ||
