* * 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:----QPmPlCTvqzZ9aVJHY3DevgNwBPDO+Ll8vJe/VRSBA3WYIx9K+/ohssorUItAkstwpjAtq/rgZGLMyesSkuIsO6XHYhPie2i65qZ1+ncWBUAkaTnTQ+Dcpis9c6chod4JhY4nAPjCWwU53Rk1iyr7/WGiFZJTgf+hV0vhLB6WYtJ9NV030KhLfc5+mO6SxOrDBhORt2zAVQpmUqakal8DpnfE+HVES5b7ExSih9N5n6yA4KxgGReavmtwZ94R96TC5fF42ChwvRRDaasgol6APYe2isqD3cpPdQJ6ZGh3lpZdHUAcoR3oxNWBf+r59njC7C6sZVk3bcJdhydk7ePMhTdD7g6+EPuPIgkdm9FNGzud5M4Pj1aWrvzkKfQnx3Gxy5e77XWcZnax9DmkqboYL2xoQH3sqcI12LmATSytTCNEh9TjRDFpvkVFyks0EEyI8SseXkP/04XlAtz2xMcloAQoO6CZSjBQFS0pUxtmcGmIgc0UdJ8alj01cJVNdF5WNuiP7eAjd4rGe65gyeJRjDrW8tskb7hIZs+q2OqQFDET/GCsjiZTwSfMguTbII+/5kg/EcwjXHMQ8RG8Q9lKkVHGAY5jUZcqV7hAyYKCL4VqVVdM9upMUHF8Cb64rLGWYvMkBhG8K0ZLiW+1XWvuAeOwbkkAf9EyaEYl4imv7MA=----ATTACHMENT:----OTg5MDc4MjY5MjI3NDc5NCA5MjI0OTM4Njk1Mjc1MzY2IDE3NTkwMjk5OTEzNzc4MjM=