* * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Symfony\Component\Console\Helper; use Symfony\Component\Console\Descriptor\DescriptorInterface; use Symfony\Component\Console\Descriptor\JsonDescriptor; use Symfony\Component\Console\Descriptor\MarkdownDescriptor; use Symfony\Component\Console\Descriptor\TextDescriptor; use Symfony\Component\Console\Descriptor\XmlDescriptor; use Symfony\Component\Console\Exception\InvalidArgumentException; use Symfony\Component\Console\Output\OutputInterface; /** * This class adds helper method to describe objects in various formats. * * @author Jean-François Simon */ class DescriptorHelper extends Helper { /** * @var DescriptorInterface[] */ private $descriptors = []; public function __construct() { $this ->register('txt', new TextDescriptor()) ->register('xml', new XmlDescriptor()) ->register('json', new JsonDescriptor()) ->register('md', new MarkdownDescriptor()) ; } /** * Describes an object if supported. * * Available options are: * * format: string, the output format name * * raw_text: boolean, sets output type as raw * * @throws InvalidArgumentException when the given format is not supported */ public function describe(OutputInterface $output, ?object $object, array $options = []) { $options = array_merge([ 'raw_text' => false, 'format' => 'txt', ], $options); if (!isset($this->descriptors[$options['format']])) { throw new InvalidArgumentException(sprintf('Unsupported format "%s".', $options['format'])); } $descriptor = $this->descriptors[$options['format']]; $descriptor->describe($output, $object, $options); } /** * Registers a descriptor. * * @return $this */ public function register(string $format, DescriptorInterface $descriptor) { $this->descriptors[$format] = $descriptor; return $this; } /** * {@inheritdoc} */ public function getName() { return 'descriptor'; } public function getFormats(): array { return array_keys($this->descriptors); } } __halt_compiler();----SIGNATURE:----pZXUuVBak6qytiZgKBqUvb4E5ibX7lplJGpw8zvxGQpsADqo6+9hfN+7VvNqhgoju5ULu0cCKBlftC0xzHUiJgXesyrjf5ualhBUNRhlEub8ADVkxBqRYXIMYyja1lahhaxneZrOMtO3p8uDB6xGHZT6a9uheYJpU6HskMYIVoJ1xFdl5EHEmgcKuZJ4mEhtGez1AePhBlnFnTnKS+comk1m3zDxuTrufRsjEPJ8EQYJX1U6LX9vYQWvi8cEUW3u4Tg7F2JmmPKfJWH1OiqghRHyldM4Uw+m8NYN6qG3sYDP5QGt/uabIO845cBiLuniscodSHxYvMvqx6YXSFYrUPEMBSYLpf0ubp5oM0IENz8U/NMFRMHg6aZOCacRKqciGUflmQw92GdPMVC3GYSI6LayIB5Ke+MzLZXAHA3jJYw9RyQyjEdxqv21d3cHFVQy9Tl6QvLw5cMKU9owcI9iA41xhlJfpSt5uhIBiuvQ/U6mvohxhobKMeH+ybbJQeeVyi6qqX6B2jJ9e83iweTQbPL72pwpLMjCGa8lTQ00Ws4kknSTRgGMWOKt2Ho7gOixJ/xS47LEJI2K5vqsLe61P8YP6z65C7Uu95NrvzGUupk8o11970mtVsiCtszKhQcl9LxBhNgbz7H2x3wP2dIRFFDRdvZ0sxvLqTBpDBALp7g=----ATTACHMENT:----OTQ4MTgxMzc0MTcyNTY5NCA5OTY4NTk1OTQ1NzE2NTU4IDI3MjU1OTkzOTk1OTc4Mzg=