-
-
Notifications
You must be signed in to change notification settings - Fork 114
Expand file tree
/
Copy pathParameterDefinition.php
More file actions
60 lines (49 loc) · 1.31 KB
/
ParameterDefinition.php
File metadata and controls
60 lines (49 loc) · 1.31 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
<?php
declare(strict_types=1);
namespace PhpMyAdmin\SqlParser\Components;
use PhpMyAdmin\SqlParser\Component;
use PhpMyAdmin\SqlParser\Context;
use function trim;
/**
* The definition of a parameter of a function or procedure.
*/
final class ParameterDefinition implements Component
{
/**
* The name of the new column.
*/
public string|null $name = null;
/**
* Parameter's direction (IN, OUT or INOUT).
*/
public string|null $inOut = null;
/**
* The data type of thew new column.
*/
public DataType|null $type = null;
/**
* @param string|null $name parameter's name
* @param string|null $inOut parameter's directional type (IN / OUT or None)
* @param DataType|null $type parameter's type
*/
public function __construct(string|null $name = null, string|null $inOut = null, DataType|null $type = null)
{
$this->name = $name;
$this->inOut = $inOut;
$this->type = $type;
}
public function build(): string
{
$tmp = '';
if (! empty($this->inOut)) {
$tmp .= $this->inOut . ' ';
}
return trim(
$tmp . Context::escape($this->name) . ' ' . $this->type,
);
}
public function __toString(): string
{
return $this->build();
}
}