MIOLO20
Carregando...
Procurando...
Nenhuma entrada encontrada
InputArgument.php
Ir para a documentação deste ficheiro.
1
<?php
2
3
namespace
Symfony\Component\Console\Input
;
4
5
/*
6
* This file is part of the Symfony framework.
7
*
8
* (c) Fabien Potencier <fabien.potencier@symfony-project.com>
9
*
10
* This source file is subject to the MIT license that is bundled
11
* with this source code in the file LICENSE.
12
*/
13
19
class
InputArgument
20
{
21
const
REQUIRED
= 1;
22
const
OPTIONAL
= 2;
23
const
IS_ARRAY
= 4;
24
25
protected
$name
;
26
protected
$mode
;
27
protected
$default
;
28
protected
$description
;
29
40
public
function
__construct
(
$name
,
$mode
=
null
,
$description
=
''
,
$default
=
null
)
41
{
42
if
(
null
===
$mode
) {
43
$mode
=
self::OPTIONAL
;
44
}
else
if
(is_string(
$mode
) ||
$mode
> 7) {
45
throw
new \InvalidArgumentException(sprintf(
'Argument mode "%s" is not valid.'
,
$mode
));
46
}
47
48
$this->name =
$name
;
49
$this->mode =
$mode
;
50
$this->description =
$description
;
51
52
$this->
setDefault
(
$default
);
53
}
54
60
public
function
getName
()
61
{
62
return
$this->name
;
63
}
64
70
public
function
isRequired
()
71
{
72
return
self::REQUIRED === (self::REQUIRED &
$this->mode
);
73
}
74
80
public
function
isArray
()
81
{
82
return
self::IS_ARRAY === (self::IS_ARRAY &
$this->mode
);
83
}
84
92
public
function
setDefault
(
$default
=
null
)
93
{
94
if
(self::REQUIRED === $this->mode &&
null
!==
$default
) {
95
throw
new \LogicException(
'Cannot set a default value except for Parameter::OPTIONAL mode.'
);
96
}
97
98
if
($this->
isArray
()) {
99
if
(
null
===
$default
) {
100
$default
= array();
101
}
else
if
(!is_array(
$default
)) {
102
throw
new \LogicException(
'A default value for an array argument must be an array.'
);
103
}
104
}
105
106
$this->
default
=
$default
;
107
}
108
114
public
function
getDefault
()
115
{
116
return
$this->default
;
117
}
118
124
public
function
getDescription
()
125
{
126
return
$this->description
;
127
}
128
}
Symfony\Component\Console\Input\InputArgument
Definição
InputArgument.php:20
Symfony\Component\Console\Input\InputArgument\OPTIONAL
const OPTIONAL
Definição
InputArgument.php:22
Symfony\Component\Console\Input\InputArgument\getDescription
getDescription()
Definição
InputArgument.php:124
Symfony\Component\Console\Input\InputArgument\isArray
isArray()
Definição
InputArgument.php:80
Symfony\Component\Console\Input\InputArgument\$mode
$mode
Definição
InputArgument.php:26
Symfony\Component\Console\Input\InputArgument\getName
getName()
Definição
InputArgument.php:60
Symfony\Component\Console\Input\InputArgument\REQUIRED
const REQUIRED
Definição
InputArgument.php:21
Symfony\Component\Console\Input\InputArgument\$description
$description
Definição
InputArgument.php:28
Symfony\Component\Console\Input\InputArgument\__construct
__construct($name, $mode=null, $description='', $default=null)
Definição
InputArgument.php:40
Symfony\Component\Console\Input\InputArgument\$default
$default
Definição
InputArgument.php:27
Symfony\Component\Console\Input\InputArgument\setDefault
setDefault($default=null)
Definição
InputArgument.php:92
Symfony\Component\Console\Input\InputArgument\$name
$name
Definição
InputArgument.php:25
Symfony\Component\Console\Input\InputArgument\isRequired
isRequired()
Definição
InputArgument.php:70
Symfony\Component\Console\Input\InputArgument\getDefault
getDefault()
Definição
InputArgument.php:114
Symfony\Component\Console\Input\InputArgument\IS_ARRAY
const IS_ARRAY
Definição
InputArgument.php:23
Symfony\Component\Console\Input
Definição
ArgvInput.php:3
classes
extensions
doctrine-dbal
Doctrine
Symfony
Component
Console
Input
InputArgument.php
Gerado por
1.10.0