@@ -30,7 +30,7 @@ |
||
30 | 30 | |
31 | 31 | public function getStatement() : string { |
32 | 32 | |
33 | - return ("`" . $this->name . "` tinyint(1) UNSIGNED NOT NULL DEFAULT '" . intval($this->default) . "'"); |
|
33 | + return ("`".$this->name."` tinyint(1) UNSIGNED NOT NULL DEFAULT '".intval($this->default)."'"); |
|
34 | 34 | } |
35 | 35 | |
36 | 36 | /** |
@@ -21,7 +21,9 @@ |
||
21 | 21 | |
22 | 22 | public function __construct(string $name, bool $default = false) { |
23 | 23 | |
24 | - foreach (get_defined_vars() as $name => $value) $this->$name = $value; |
|
24 | + foreach (get_defined_vars() as $name => $value) { |
|
25 | + $this->$name = $value; |
|
26 | + } |
|
25 | 27 | } |
26 | 28 | |
27 | 29 | /** |
@@ -32,7 +32,7 @@ |
||
32 | 32 | |
33 | 33 | return ("`" . $this->name . "` " . ($this->short ? ("varchar(" . $this->length . ")") : "text")) . |
34 | 34 | |
35 | - (($this->binary ? " BINARY" : "") . " NOT NULL DEFAULT '" . $this->default . "'"); |
|
35 | + (($this->binary ? " BINARY" : "") . " NOT NULL DEFAULT '" . $this->default . "'"); |
|
36 | 36 | } |
37 | 37 | |
38 | 38 | /** |
@@ -30,9 +30,9 @@ |
||
30 | 30 | |
31 | 31 | public function getStatement() : string { |
32 | 32 | |
33 | - return ("`" . $this->name . "` " . ($this->short ? ("varchar(" . $this->length . ")") : "text")) . |
|
33 | + return ("`".$this->name."` ".($this->short ? ("varchar(".$this->length.")") : "text")). |
|
34 | 34 | |
35 | - (($this->binary ? " BINARY" : "") . " NOT NULL DEFAULT '" . $this->default . "'"); |
|
35 | + (($this->binary ? " BINARY" : "")." NOT NULL DEFAULT '".$this->default."'"); |
|
36 | 36 | } |
37 | 37 | |
38 | 38 | /** |
@@ -21,7 +21,9 @@ |
||
21 | 21 | |
22 | 22 | public function __construct(string $name, bool $short = true, int $length = 0, bool $binary = false, string $default = '') { |
23 | 23 | |
24 | - foreach (get_defined_vars() as $name => $value) $this->$name = $value; |
|
24 | + foreach (get_defined_vars() as $name => $value) { |
|
25 | + $this->$name = $value; |
|
26 | + } |
|
25 | 27 | } |
26 | 28 | |
27 | 29 | /** |
@@ -30,7 +30,7 @@ |
||
30 | 30 | |
31 | 31 | public function getStatement() : string { |
32 | 32 | |
33 | - return ("`" . $this->name . "` int(10) UNSIGNED NOT NULL" . ($this->auto_increment ? " AUTO_INCREMENT" : "")); |
|
33 | + return ("`".$this->name."` int(10) UNSIGNED NOT NULL".($this->auto_increment ? " AUTO_INCREMENT" : "")); |
|
34 | 34 | } |
35 | 35 | |
36 | 36 | /** |
@@ -45,9 +45,9 @@ |
||
45 | 45 | |
46 | 46 | public function getStatement() : string { |
47 | 47 | |
48 | - return ((null !== $this->type) ? ($this->type . " ") : "") . |
|
48 | + return ((null !== $this->type) ? ($this->type." ") : ""). |
|
49 | 49 | |
50 | - ("KEY `" . $this->name . "` (`" . $this->name . "`)"); |
|
50 | + ("KEY `".$this->name."` (`".$this->name."`)"); |
|
51 | 51 | } |
52 | 52 | } |
53 | 53 | } |
@@ -36,7 +36,9 @@ |
||
36 | 36 | |
37 | 37 | $this->name = $name; |
38 | 38 | |
39 | - if (null !== $type) $this->type = $this->validateType($type); |
|
39 | + if (null !== $type) { |
|
40 | + $this->type = $this->validateType($type); |
|
41 | + } |
|
40 | 42 | } |
41 | 43 | |
42 | 44 | /** |
@@ -19,7 +19,9 @@ |
||
19 | 19 | |
20 | 20 | public function add(string $name, string $table, string $field, string $delete = null, string $update = null) { |
21 | 21 | |
22 | - if ((false === $this->definition->getParam($name)) || isset($this->list[$name])) return; |
|
22 | + if ((false === $this->definition->getParam($name)) || isset($this->list[$name])) { |
|
23 | + return; |
|
24 | + } |
|
23 | 25 | |
24 | 26 | $this->list[$name] = new Definition\Item\Foreign($name, $table, $field, $delete, $update); |
25 | 27 | } |
@@ -30,7 +30,9 @@ |
||
30 | 30 | |
31 | 31 | public function add(string $name, string $type = null) { |
32 | 32 | |
33 | - if ((false === $this->definition->getParam($name)) || isset($this->list[$name])) return; |
|
33 | + if ((false === $this->definition->getParam($name)) || isset($this->list[$name])) { |
|
34 | + return; |
|
35 | + } |
|
34 | 36 | |
35 | 37 | $this->list[$name] = new Definition\Item\Index($name, $type); |
36 | 38 | } |
@@ -28,11 +28,15 @@ |
||
28 | 28 | |
29 | 29 | private function add(string $type, string $name, array $args) { |
30 | 30 | |
31 | - if (('' === $name) || isset($this->list[$name])) return; |
|
31 | + if (('' === $name) || isset($this->list[$name])) { |
|
32 | + return; |
|
33 | + } |
|
32 | 34 | |
33 | 35 | $this->list[$name] = new $this->types[$type](...$args); |
34 | 36 | |
35 | - if (($type !== 'textual') || $this->list[$name]->short) $this->secure[] = $name; |
|
37 | + if (($type !== 'textual') || $this->list[$name]->short) { |
|
38 | + $this->secure[] = $name; |
|
39 | + } |
|
36 | 40 | } |
37 | 41 | |
38 | 42 | /** |
@@ -45,7 +45,7 @@ discard block |
||
45 | 45 | |
46 | 46 | $selection = []; |
47 | 47 | |
48 | - foreach ($this->definition->getParamsSecure() as $field) $selection[] = ('ent.' . $field); |
|
48 | + foreach ($this->definition->getParamsSecure() as $field) $selection[] = ('ent.'.$field); |
|
49 | 49 | |
50 | 50 | # ------------------------ |
51 | 51 | |
@@ -60,7 +60,7 @@ discard block |
||
60 | 60 | |
61 | 61 | $order_by = []; |
62 | 62 | |
63 | - foreach ($this->castOrderBy($data) as $field => $direction) $order_by[] = ('ent.' . $field . ' ' . $direction); |
|
63 | + foreach ($this->castOrderBy($data) as $field => $direction) $order_by[] = ('ent.'.$field.' '.$direction); |
|
64 | 64 | |
65 | 65 | # ------------------------ |
66 | 66 |
@@ -27,7 +27,9 @@ discard block |
||
27 | 27 | |
28 | 28 | foreach ($data as $field => $direction) { |
29 | 29 | |
30 | - if (false === ($param = $this->definition->getParam($field))) continue; |
|
30 | + if (false === ($param = $this->definition->getParam($field))) { |
|
31 | + continue; |
|
32 | + } |
|
31 | 33 | |
32 | 34 | $order_by[$param->name] = ((strtoupper($direction) !== 'DESC') ? 'ASC' : 'DESC'); |
33 | 35 | } |
@@ -45,7 +47,9 @@ discard block |
||
45 | 47 | |
46 | 48 | $selection = []; |
47 | 49 | |
48 | - foreach ($this->definition->getParamsSecure() as $field) $selection[] = ('ent.' . $field); |
|
50 | + foreach ($this->definition->getParamsSecure() as $field) { |
|
51 | + $selection[] = ('ent.' . $field); |
|
52 | + } |
|
49 | 53 | |
50 | 54 | # ------------------------ |
51 | 55 | |
@@ -60,7 +64,9 @@ discard block |
||
60 | 64 | |
61 | 65 | $order_by = []; |
62 | 66 | |
63 | - foreach ($this->castOrderBy($data) as $field => $direction) $order_by[] = ('ent.' . $field . ' ' . $direction); |
|
67 | + foreach ($this->castOrderBy($data) as $field => $direction) { |
|
68 | + $order_by[] = ('ent.' . $field . ' ' . $direction); |
|
69 | + } |
|
64 | 70 | |
65 | 71 | # ------------------------ |
66 | 72 |
@@ -41,9 +41,9 @@ discard block |
||
41 | 41 | |
42 | 42 | private function createMainTable() : bool { |
43 | 43 | |
44 | - $query = ("CREATE TABLE IF NOT EXISTS `" . static::$table . "` (") . |
|
44 | + $query = ("CREATE TABLE IF NOT EXISTS `".static::$table."` ("). |
|
45 | 45 | |
46 | - implode(", ", $this->getStatements()) . |
|
46 | + implode(", ", $this->getStatements()). |
|
47 | 47 | |
48 | 48 | (") ENGINE=InnoDB DEFAULT CHARSET=utf8"); |
49 | 49 | |
@@ -60,17 +60,17 @@ discard block |
||
60 | 60 | |
61 | 61 | private function createRelationsTable() : bool { |
62 | 62 | |
63 | - $query = ("CREATE TABLE IF NOT EXISTS `" . static::$table_relations . "` (") . |
|
63 | + $query = ("CREATE TABLE IF NOT EXISTS `".static::$table_relations."` ("). |
|
64 | 64 | |
65 | - ("`ancestor` int(10) UNSIGNED NOT NULL, `descendant` int(10) UNSIGNED NOT NULL, ") . |
|
65 | + ("`ancestor` int(10) UNSIGNED NOT NULL, `descendant` int(10) UNSIGNED NOT NULL, "). |
|
66 | 66 | |
67 | - ("`depth` int(10) UNSIGNED NOT NULL, ") . |
|
67 | + ("`depth` int(10) UNSIGNED NOT NULL, "). |
|
68 | 68 | |
69 | - ("PRIMARY KEY (`ancestor`, `descendant`), KEY (`ancestor`), KEY (`descendant`), KEY (`depth`), ") . |
|
69 | + ("PRIMARY KEY (`ancestor`, `descendant`), KEY (`ancestor`), KEY (`descendant`), KEY (`depth`), "). |
|
70 | 70 | |
71 | - ("FOREIGN KEY (`ancestor`) REFERENCES `" . static::$table . "` (`id`) ON DELETE CASCADE, ") . |
|
71 | + ("FOREIGN KEY (`ancestor`) REFERENCES `".static::$table."` (`id`) ON DELETE CASCADE, "). |
|
72 | 72 | |
73 | - ("FOREIGN KEY (`descendant`) REFERENCES `" . static::$table . "` (`id`) ON DELETE CASCADE ") . |
|
73 | + ("FOREIGN KEY (`descendant`) REFERENCES `".static::$table."` (`id`) ON DELETE CASCADE "). |
|
74 | 74 | |
75 | 75 | (") ENGINE=InnoDB DEFAULT CHARSET=utf8"); |
76 | 76 | |
@@ -87,7 +87,7 @@ discard block |
||
87 | 87 | |
88 | 88 | private function removeMainTable() : bool { |
89 | 89 | |
90 | - $query = ("DROP TABLE IF EXISTS `" . static::$table . "`"); |
|
90 | + $query = ("DROP TABLE IF EXISTS `".static::$table."`"); |
|
91 | 91 | |
92 | 92 | return (DB::send($query) && DB::getLast()->status); |
93 | 93 | } |
@@ -100,7 +100,7 @@ discard block |
||
100 | 100 | |
101 | 101 | private function removeRelationsTable() : bool { |
102 | 102 | |
103 | - $query = ("DROP TABLE IF EXISTS `" . static::$table_relations . "`"); |
|
103 | + $query = ("DROP TABLE IF EXISTS `".static::$table_relations."`"); |
|
104 | 104 | |
105 | 105 | return (DB::send($query) && DB::getLast()->status); |
106 | 106 | } |
@@ -25,7 +25,9 @@ |
||
25 | 25 | |
26 | 26 | foreach ([$this->params, $this->indexes, $this->foreigns] as $group) { |
27 | 27 | |
28 | - foreach ($group->getList() as $item) $statements[] = $item->getStatement(); |
|
28 | + foreach ($group->getList() as $item) { |
|
29 | + $statements[] = $item->getStatement(); |
|
30 | + } |
|
29 | 31 | } |
30 | 32 | |
31 | 33 | # ------------------------ |