Subversion-Projekte lars-tiefland.laravel_shop

Revision

Revision 148 | Details | Vergleich mit vorheriger | Letzte Änderung | Log anzeigen | RSS feed

Revision Autor Zeilennr. Zeile
148 lars 1
<?php
2
 
3
/*
4
 * This file is part of Psy Shell.
5
 *
200 lars 6
 * (c) 2012-2023 Justin Hileman
148 lars 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 Psy\Input;
13
 
14
use Symfony\Component\Console\Input\InputArgument;
15
 
16
/**
17
 * An input argument for code.
18
 *
19
 * A CodeArgument must be the final argument of the command. Once all options
20
 * and other arguments are used, any remaining input until the end of the string
21
 * is considered part of a single CodeArgument, regardless of spaces, quoting,
22
 * escaping, etc.
23
 *
24
 * This means commands can support crazy input like
25
 *
26
 *     parse function() { return "wheee\n"; }
27
 *
28
 * ... without having to put the code in a quoted string and escape everything.
29
 */
30
class CodeArgument extends InputArgument
31
{
32
    /**
33
     * Constructor.
34
     *
35
     * @param string $name        The argument name
36
     * @param int    $mode        The argument mode: self::REQUIRED or self::OPTIONAL
37
     * @param string $description A description text
38
     * @param mixed  $default     The default value (for self::OPTIONAL mode only)
39
     *
40
     * @throws \InvalidArgumentException When argument mode is not valid
41
     */
42
    public function __construct(string $name, int $mode = null, string $description = '', $default = null)
43
    {
44
        if ($mode & InputArgument::IS_ARRAY) {
45
            throw new \InvalidArgumentException('Argument mode IS_ARRAY is not valid');
46
        }
47
 
48
        parent::__construct($name, $mode, $description, $default);
49
    }
50
}