Subversion-Projekte lars-tiefland.laravel_shop

Revision

Details | Letzte Änderung | Log anzeigen | RSS feed

Revision Autor Zeilennr. Zeile
148 lars 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
    public function describe(OutputInterface $output, object $object, array $options = [])
35
    {
36
        $this->output = $output;
37
 
38
        match (true) {
39
            $object instanceof InputArgument => $this->describeInputArgument($object, $options),
40
            $object instanceof InputOption => $this->describeInputOption($object, $options),
41
            $object instanceof InputDefinition => $this->describeInputDefinition($object, $options),
42
            $object instanceof Command => $this->describeCommand($object, $options),
43
            $object instanceof Application => $this->describeApplication($object, $options),
44
            default => throw new InvalidArgumentException(sprintf('Object of type "%s" is not describable.', get_debug_type($object))),
45
        };
46
    }
47
 
48
    /**
49
     * Writes content to output.
50
     */
51
    protected function write(string $content, bool $decorated = false)
52
    {
53
        $this->output->write($content, false, $decorated ? OutputInterface::OUTPUT_NORMAL : OutputInterface::OUTPUT_RAW);
54
    }
55
 
56
    /**
57
     * Describes an InputArgument instance.
58
     */
59
    abstract protected function describeInputArgument(InputArgument $argument, array $options = []);
60
 
61
    /**
62
     * Describes an InputOption instance.
63
     */
64
    abstract protected function describeInputOption(InputOption $option, array $options = []);
65
 
66
    /**
67
     * Describes an InputDefinition instance.
68
     */
69
    abstract protected function describeInputDefinition(InputDefinition $definition, array $options = []);
70
 
71
    /**
72
     * Describes a Command instance.
73
     */
74
    abstract protected function describeCommand(Command $command, array $options = []);
75
 
76
    /**
77
     * Describes an Application instance.
78
     */
79
    abstract protected function describeApplication(Application $application, array $options = []);
80
}