Passed
Branch 0.3.0 (b16461)
by Anton
03:34
created

Params::secure()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %
Metric Value
dl 0
loc 4
rs 10
cc 1
eloc 2
nc 1
nop 0
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) {
0 ignored issues
show
Unused Code introduced by
The parameter $default is not used and could be removed.

This check looks from parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
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) {
0 ignored issues
show
Unused Code introduced by
The parameter $short is not used and could be removed.

This check looks from parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
Unused Code introduced by
The parameter $length is not used and could be removed.

This check looks from parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
Unused Code introduced by
The parameter $unsigned is not used and could be removed.

This check looks from parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
Unused Code introduced by
The parameter $default is not used and could be removed.

This check looks from parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
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 = '') {
0 ignored issues
show
Unused Code introduced by
The parameter $short is not used and could be removed.

This check looks from parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
Unused Code introduced by
The parameter $length is not used and could be removed.

This check looks from parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
Unused Code introduced by
The parameter $binary is not used and could be removed.

This check looks from parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
Unused Code introduced by
The parameter $default is not used and could be removed.

This check looks from parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
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