|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
namespace Modules\Entitizer\Utils\Definition\Group { |
|
4
|
|
|
|
|
5
|
|
|
use Modules\Entitizer\Utils\Definition; |
|
6
|
|
|
|
|
7
|
|
|
class Params extends Definition\Group { |
|
8
|
|
|
|
|
9
|
|
|
private $secure = []; |
|
10
|
|
|
|
|
11
|
|
|
private $types = [ |
|
12
|
|
|
|
|
13
|
|
|
'boolean' => 'Modules\Entitizer\Utils\Definition\Item\Param\Type\Boolean', |
|
14
|
|
|
'integer' => 'Modules\Entitizer\Utils\Definition\Item\Param\Type\Integer', |
|
15
|
|
|
'textual' => 'Modules\Entitizer\Utils\Definition\Item\Param\Type\Textual' |
|
16
|
|
|
]; |
|
17
|
|
|
|
|
18
|
|
|
# Add param |
|
19
|
|
|
|
|
20
|
|
|
private function add(string $type, string $name, array $args) { |
|
21
|
|
|
|
|
22
|
|
|
if (('' === $name) || isset($this->list[$name])) return; |
|
23
|
|
|
|
|
24
|
|
|
$this->list[$name] = new $this->types[$type](...$args); |
|
25
|
|
|
|
|
26
|
|
|
if (($type !== 'textual') || $this->list[$name]->short) $this->secure[] = $name; |
|
27
|
|
|
} |
|
28
|
|
|
|
|
29
|
|
|
# Constructor |
|
30
|
|
|
|
|
31
|
|
|
public function __construct(Definition $definition, bool $auto_increment) { |
|
32
|
|
|
|
|
33
|
|
|
parent::__construct($definition); |
|
34
|
|
|
|
|
35
|
|
|
$this->list['id'] = new Definition\Item\Param\Id($auto_increment); |
|
36
|
|
|
|
|
37
|
|
|
$this->secure[] = 'id'; |
|
38
|
|
|
} |
|
39
|
|
|
|
|
40
|
|
|
# Add boolean param |
|
41
|
|
|
|
|
42
|
|
|
public function boolean(string $name, bool $default = false) { |
|
|
|
|
|
|
43
|
|
|
|
|
44
|
|
|
$this->add('boolean', $name, func_get_args()); |
|
45
|
|
|
} |
|
46
|
|
|
|
|
47
|
|
|
# Add integer param |
|
48
|
|
|
|
|
49
|
|
|
public function integer(string $name, bool $short = false, int $length = 0, bool $unsigned = false, int $default = 0) { |
|
|
|
|
|
|
50
|
|
|
|
|
51
|
|
|
$this->add('integer', $name, func_get_args()); |
|
52
|
|
|
} |
|
53
|
|
|
|
|
54
|
|
|
# Add textual param |
|
55
|
|
|
|
|
56
|
|
|
public function textual(string $name, bool $short = true, int $length = 0, bool $binary = false, string $default = '') { |
|
|
|
|
|
|
57
|
|
|
|
|
58
|
|
|
$this->add('textual', $name, func_get_args()); |
|
59
|
|
|
} |
|
60
|
|
|
|
|
61
|
|
|
# Return secure params list |
|
62
|
|
|
|
|
63
|
|
|
public function secure() { |
|
64
|
|
|
|
|
65
|
|
|
return $this->secure; |
|
66
|
|
|
} |
|
67
|
|
|
} |
|
68
|
|
|
} |
|
69
|
|
|
|
This check looks from parameters that have been defined for a function or method, but which are not used in the method body.