Passed
Pull Request — master (#16)
by Anton
03:45
created
www/engine/System/Classes/Modules/Entitizer/Definition/Variable.php 1 patch
Spacing   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -14,14 +14,14 @@
 block discarded – undo
14 14
 
15 15
 			# Add params
16 16
 
17
-			$this->params->textual      ('name',                true, 255, false, '');
18
-			$this->params->textual      ('title',               true, 255, false, '');
19
-			$this->params->textual      ('value',               true, 255, false, '');
17
+			$this->params->textual('name', true, 255, false, '');
18
+			$this->params->textual('title', true, 255, false, '');
19
+			$this->params->textual('value', true, 255, false, '');
20 20
 
21 21
 			# Add indexes
22 22
 
23
-			$this->indexes->add         ('name',                'UNIQUE');
24
-			$this->indexes->add         ('title');
23
+			$this->indexes->add('name', 'UNIQUE');
24
+			$this->indexes->add('title');
25 25
 		}
26 26
 	}
27 27
 }
Please login to merge, or discard this patch.
www/engine/System/Classes/Modules/Entitizer/Definition/User.php 1 patch
Spacing   +18 added lines, -18 removed lines patch added patch discarded remove patch
@@ -14,27 +14,27 @@
 block discarded – undo
14 14
 
15 15
 			# Add params
16 16
 
17
-			$this->params->integer      ('rank',                true, 1, true, RANK_GUEST);
18
-			$this->params->textual      ('name',                true, 16, false, '');
19
-			$this->params->textual      ('email',               true, 128, false, '');
20
-			$this->params->textual      ('auth_key',            true, 40, true, '');
21
-			$this->params->textual      ('password',            true, 40, true, '');
22
-			$this->params->textual      ('first_name',          true, 255, false, '');
23
-			$this->params->textual      ('last_name',           true, 255, false, '');
24
-			$this->params->integer      ('sex',                 true, 1, true, SEX_NOT_SELECTED);
25
-			$this->params->textual      ('city',                true, 255, false, '');
26
-			$this->params->textual      ('country',             true, 2, false, '');
27
-			$this->params->textual      ('timezone',            true, 40, false, '');
28
-			$this->params->integer      ('time_registered',     false, 10, true, 0);
29
-			$this->params->integer      ('time_logged',         false, 10, true, 0);
17
+			$this->params->integer('rank', true, 1, true, RANK_GUEST);
18
+			$this->params->textual('name', true, 16, false, '');
19
+			$this->params->textual('email', true, 128, false, '');
20
+			$this->params->textual('auth_key', true, 40, true, '');
21
+			$this->params->textual('password', true, 40, true, '');
22
+			$this->params->textual('first_name', true, 255, false, '');
23
+			$this->params->textual('last_name', true, 255, false, '');
24
+			$this->params->integer('sex', true, 1, true, SEX_NOT_SELECTED);
25
+			$this->params->textual('city', true, 255, false, '');
26
+			$this->params->textual('country', true, 2, false, '');
27
+			$this->params->textual('timezone', true, 40, false, '');
28
+			$this->params->integer('time_registered', false, 10, true, 0);
29
+			$this->params->integer('time_logged', false, 10, true, 0);
30 30
 
31 31
 			# Add indexes
32 32
 
33
-			$this->indexes->add         ('rank');
34
-			$this->indexes->add         ('name',                'UNIQUE');
35
-			$this->indexes->add         ('email',               'UNIQUE');
36
-			$this->indexes->add         ('time_registered');
37
-			$this->indexes->add         ('time_logged');
33
+			$this->indexes->add('rank');
34
+			$this->indexes->add('name', 'UNIQUE');
35
+			$this->indexes->add('email', 'UNIQUE');
36
+			$this->indexes->add('time_registered');
37
+			$this->indexes->add('time_logged');
38 38
 		}
39 39
 	}
40 40
 }
Please login to merge, or discard this patch.
www/engine/System/Classes/Modules/Entitizer/Controller/Page.php 1 patch
Braces   +6 added lines, -2 removed lines patch added patch discarded remove patch
@@ -44,11 +44,15 @@
 block discarded – undo
44 44
 			$data['contents']           = $contents;
45 45
 			$data['time_modified']      = REQUEST_TIME;
46 46
 
47
-			if (0 === $this->page->id) $data['time_created'] = REQUEST_TIME;
47
+			if (0 === $this->page->id) {
48
+				$data['time_created'] = REQUEST_TIME;
49
+			}
48 50
 
49 51
 			$modifier = ((0 === $this->page->id) ? 'create' : 'edit');
50 52
 
51
-			if (!$this->page->$modifier($data)) return 'PAGE_ERROR_MODIFY';
53
+			if (!$this->page->$modifier($data)) {
54
+				return 'PAGE_ERROR_MODIFY';
55
+			}
52 56
 
53 57
 			# ------------------------
54 58
 
Please login to merge, or discard this patch.
www/engine/System/Classes/Modules/Entitizer/Controller/User.php 1 patch
Braces   +27 added lines, -9 removed lines patch added patch discarded remove patch
@@ -31,30 +31,46 @@  discard block
 block discarded – undo
31 31
 
32 32
 			# Validate name & email
33 33
 
34
-			if (false === ($name = Validate::userName($name))) return ['name', 'USER_ERROR_NAME_INVALID'];
34
+			if (false === ($name = Validate::userName($name))) {
35
+				return ['name', 'USER_ERROR_NAME_INVALID'];
36
+			}
35 37
 
36
-			if (false === ($email = Validate::userEmail($email))) return ['email', 'USER_ERROR_EMAIL_INVALID'];
38
+			if (false === ($email = Validate::userEmail($email))) {
39
+				return ['email', 'USER_ERROR_EMAIL_INVALID'];
40
+			}
37 41
 
38 42
 			# Validate password
39 43
 
40 44
 			if ((0 === $this->user->id) || ('' !== $password)) {
41 45
 
42
-				if (false === ($password = Validate::userPassword($password))) return ['password', 'USER_ERROR_PASSWORD_INVALID'];
46
+				if (false === ($password = Validate::userPassword($password))) {
47
+					return ['password', 'USER_ERROR_PASSWORD_INVALID'];
48
+				}
43 49
 
44
-				if (0 !== strcmp($password, $password_retype)) return ['password_retype', 'USER_ERROR_PASSWORD_MISMATCH'];
50
+				if (0 !== strcmp($password, $password_retype)) {
51
+					return ['password_retype', 'USER_ERROR_PASSWORD_MISMATCH'];
52
+				}
45 53
 			}
46 54
 
47 55
 			# Check name exists
48 56
 
49
-			if (false === ($check_name = $this->user->check($name, 'name'))) return 'USER_ERROR_MODIFY';
57
+			if (false === ($check_name = $this->user->check($name, 'name'))) {
58
+				return 'USER_ERROR_MODIFY';
59
+			}
50 60
 
51
-			if ($check_name === 1) return ['name', 'USER_ERROR_NAME_DUPLICATE'];
61
+			if ($check_name === 1) {
62
+				return ['name', 'USER_ERROR_NAME_DUPLICATE'];
63
+			}
52 64
 
53 65
 			# Check email exists
54 66
 
55
-			if (false === ($check_email = $this->user->check($email, 'email'))) return 'USER_ERROR_MODIFY';
67
+			if (false === ($check_email = $this->user->check($email, 'email'))) {
68
+				return 'USER_ERROR_MODIFY';
69
+			}
56 70
 
57
-			if ($check_email === 1) return ['email', 'USER_ERROR_EMAIL_DUPLICATE'];
71
+			if ($check_email === 1) {
72
+				return ['email', 'USER_ERROR_EMAIL_DUPLICATE'];
73
+			}
58 74
 
59 75
 			# Modify user
60 76
 
@@ -84,7 +100,9 @@  discard block
 block discarded – undo
84 100
 
85 101
 			$modifier = ((0 === $this->user->id) ? 'create' : 'edit');
86 102
 
87
-			if (!$this->user->$modifier($data)) return 'USER_ERROR_MODIFY';
103
+			if (!$this->user->$modifier($data)) {
104
+				return 'USER_ERROR_MODIFY';
105
+			}
88 106
 
89 107
 			# ------------------------
90 108
 
Please login to merge, or discard this patch.
www/engine/System/Classes/Modules/Entitizer/Utils/Collection.php 2 patches
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -32,7 +32,7 @@  discard block
 block discarded – undo
32 32
 
33 33
 			$selection = [];
34 34
 
35
-			foreach ($this->definition->paramsSecure() as $field) $selection[] = ('ent.' . $field);
35
+			foreach ($this->definition->paramsSecure() as $field) $selection[] = ('ent.'.$field);
36 36
 
37 37
 			# ------------------------
38 38
 
@@ -45,7 +45,7 @@  discard block
 block discarded – undo
45 45
 
46 46
 			$order_by = [];
47 47
 
48
-			foreach ($this->castOrderBy($data) as $field => $direction) $order_by[] = ('ent.' . $field . ' ' . $direction);
48
+			foreach ($this->castOrderBy($data) as $field => $direction) $order_by[] = ('ent.'.$field.' '.$direction);
49 49
 
50 50
 			# ------------------------
51 51
 
Please login to merge, or discard this patch.
Braces   +9 added lines, -3 removed lines patch added patch discarded remove patch
@@ -16,7 +16,9 @@  discard block
 block discarded – undo
16 16
 
17 17
 			foreach ($data as $field => $direction) {
18 18
 
19
-				if (false === ($param = $this->definition->param($field))) continue;
19
+				if (false === ($param = $this->definition->param($field))) {
20
+					continue;
21
+				}
20 22
 
21 23
 				$order_by[$param->name] = ((strtoupper($direction) !== 'DESC') ? 'ASC' : 'DESC');
22 24
 			}
@@ -32,7 +34,9 @@  discard block
 block discarded – undo
32 34
 
33 35
 			$selection = [];
34 36
 
35
-			foreach ($this->definition->paramsSecure() as $field) $selection[] = ('ent.' . $field);
37
+			foreach ($this->definition->paramsSecure() as $field) {
38
+				$selection[] = ('ent.' . $field);
39
+			}
36 40
 
37 41
 			# ------------------------
38 42
 
@@ -45,7 +49,9 @@  discard block
 block discarded – undo
45 49
 
46 50
 			$order_by = [];
47 51
 
48
-			foreach ($this->castOrderBy($data) as $field => $direction) $order_by[] = ('ent.' . $field . ' ' . $direction);
52
+			foreach ($this->castOrderBy($data) as $field => $direction) {
53
+				$order_by[] = ('ent.' . $field . ' ' . $direction);
54
+			}
49 55
 
50 56
 			# ------------------------
51 57
 
Please login to merge, or discard this patch.
www/engine/System/Classes/Modules/Entitizer/Utils/Treeview.php 3 patches
Indentation   +8 added lines, -8 removed lines patch added patch discarded remove patch
@@ -12,7 +12,7 @@  discard block
 block discarded – undo
12 12
 
13 13
 			return (0 !== $parent_id) ? (("JOIN " . static::$table_relations . " rel ") .
14 14
 
15
-			       ("ON rel.ancestor = " . $parent_id . " AND rel.descendant = ent.id AND rel.depth >= 1")) :
15
+				   ("ON rel.ancestor = " . $parent_id . " AND rel.descendant = ent.id AND rel.depth >= 1")) :
16 16
 
17 17
 				   ("JOIN " . static::$table_relations . " rel ON rel.descendant = ent.id");
18 18
 		}
@@ -23,13 +23,13 @@  discard block
 block discarded – undo
23 23
 
24 24
 			return ("SELECT " . $this->getSelection() . ", COALESCE(par.ancestor, 0) as parent_id ") .
25 25
 
26
-			       ("FROM " . static::$table . " ent " . $this->getQueryJoin($parent_id) . " ") .
26
+				   ("FROM " . static::$table . " ent " . $this->getQueryJoin($parent_id) . " ") .
27 27
 
28
-			       ("LEFT JOIN " . static::$table_relations . " par ON par.descendant = ent.id AND par.depth = 1 ") .
28
+				   ("LEFT JOIN " . static::$table_relations . " par ON par.descendant = ent.id AND par.depth = 1 ") .
29 29
 
30
-			       (('' !== ($condition = $this->getCondition($config))) ? ("WHERE " . $condition . " ") : "") .
30
+				   (('' !== ($condition = $this->getCondition($config))) ? ("WHERE " . $condition . " ") : "") .
31 31
 
32
-			       ("GROUP BY ent.id ORDER BY MAX(rel.depth) ASC, " . $this->getOrderBy($order_by));
32
+				   ("GROUP BY ent.id ORDER BY MAX(rel.depth) ASC, " . $this->getOrderBy($order_by));
33 33
 		}
34 34
 
35 35
 		# Get count query
@@ -38,7 +38,7 @@  discard block
 block discarded – undo
38 38
 
39 39
 			return ("SELECT COUNT(DISTINCT ent.id) as count FROM " . static::$table . " ent ") .
40 40
 
41
-			       $this->getQueryJoin($parent_id);
41
+				   $this->getQueryJoin($parent_id);
42 42
 		}
43 43
 
44 44
 		# Get depth query
@@ -47,7 +47,7 @@  discard block
 block discarded – undo
47 47
 
48 48
 			$query = ("SELECT COUNT(DISTINCT rel.depth) as depth FROM " . static::$table . " ent ") .
49 49
 
50
-			         $this->getQueryJoin($parent_id);
50
+					 $this->getQueryJoin($parent_id);
51 51
 
52 52
 			# ------------------------
53 53
 
@@ -128,7 +128,7 @@  discard block
 block discarded – undo
128 128
 
129 129
 			$query = ("SELECT " . $this->getSelection() . " FROM " . static::$table . " ent ") .
130 130
 
131
-			         ("JOIN " . static::$table_relations . " rel ON rel.ancestor = ent.id ") .
131
+					 ("JOIN " . static::$table_relations . " rel ON rel.ancestor = ent.id ") .
132 132
 
133 133
 					 ("WHERE rel.descendant = " . $parent_id . " ORDER BY rel.depth DESC");
134 134
 
Please login to merge, or discard this patch.
Spacing   +12 added lines, -14 removed lines patch added patch discarded remove patch
@@ -10,33 +10,31 @@  discard block
 block discarded – undo
10 10
 
11 11
 		protected function getQueryJoin(int $parent_id) {
12 12
 
13
-			return (0 !== $parent_id) ? (("JOIN " . static::$table_relations . " rel ") .
13
+			return (0 !== $parent_id) ? (("JOIN ".static::$table_relations." rel ").
14 14
 
15
-			       ("ON rel.ancestor = " . $parent_id . " AND rel.descendant = ent.id AND rel.depth >= 1")) :
16
-
17
-				   ("JOIN " . static::$table_relations . " rel ON rel.descendant = ent.id");
15
+			       ("ON rel.ancestor = ".$parent_id." AND rel.descendant = ent.id AND rel.depth >= 1")) : ("JOIN ".static::$table_relations." rel ON rel.descendant = ent.id");
18 16
 		}
19 17
 
20 18
 		# Get select query
21 19
 
22 20
 		private function getSelectQuery(int $parent_id, array $config, array $order_by) {
23 21
 
24
-			return ("SELECT " . $this->getSelection() . ", COALESCE(par.ancestor, 0) as parent_id ") .
22
+			return ("SELECT ".$this->getSelection().", COALESCE(par.ancestor, 0) as parent_id ").
25 23
 
26
-			       ("FROM " . static::$table . " ent " . $this->getQueryJoin($parent_id) . " ") .
24
+			       ("FROM ".static::$table." ent ".$this->getQueryJoin($parent_id)." ").
27 25
 
28
-			       ("LEFT JOIN " . static::$table_relations . " par ON par.descendant = ent.id AND par.depth = 1 ") .
26
+			       ("LEFT JOIN ".static::$table_relations." par ON par.descendant = ent.id AND par.depth = 1 ").
29 27
 
30
-			       (('' !== ($condition = $this->getCondition($config))) ? ("WHERE " . $condition . " ") : "") .
28
+			       (('' !== ($condition = $this->getCondition($config))) ? ("WHERE ".$condition." ") : "").
31 29
 
32
-			       ("GROUP BY ent.id ORDER BY MAX(rel.depth) ASC, " . $this->getOrderBy($order_by));
30
+			       ("GROUP BY ent.id ORDER BY MAX(rel.depth) ASC, ".$this->getOrderBy($order_by));
33 31
 		}
34 32
 
35 33
 		# Get count query
36 34
 
37 35
 		private function getCountQuery(int $parent_id) {
38 36
 
39
-			return ("SELECT COUNT(DISTINCT ent.id) as count FROM " . static::$table . " ent ") .
37
+			return ("SELECT COUNT(DISTINCT ent.id) as count FROM ".static::$table." ent ").
40 38
 
41 39
 			       $this->getQueryJoin($parent_id);
42 40
 		}
@@ -45,7 +43,7 @@  discard block
 block discarded – undo
45 43
 
46 44
 		private function getDepthQuery(int $parent_id) {
47 45
 
48
-			$query = ("SELECT COUNT(DISTINCT rel.depth) as depth FROM " . static::$table . " ent ") .
46
+			$query = ("SELECT COUNT(DISTINCT rel.depth) as depth FROM ".static::$table." ent ").
49 47
 
50 48
 			         $this->getQueryJoin($parent_id);
51 49
 
@@ -126,11 +124,11 @@  discard block
 block discarded – undo
126 124
 
127 125
 			# Process query
128 126
 
129
-			$query = ("SELECT " . $this->getSelection() . " FROM " . static::$table . " ent ") .
127
+			$query = ("SELECT ".$this->getSelection()." FROM ".static::$table." ent ").
130 128
 
131
-			         ("JOIN " . static::$table_relations . " rel ON rel.ancestor = ent.id ") .
129
+			         ("JOIN ".static::$table_relations." rel ON rel.ancestor = ent.id ").
132 130
 
133
-					 ("WHERE rel.descendant = " . $parent_id . " ORDER BY rel.depth DESC");
131
+					 ("WHERE rel.descendant = ".$parent_id." ORDER BY rel.depth DESC");
134 132
 
135 133
 			# Select path
136 134
 
Please login to merge, or discard this patch.
Braces   +27 added lines, -9 removed lines patch added patch discarded remove patch
@@ -58,13 +58,17 @@  discard block
 block discarded – undo
58 58
 
59 59
 		public function subtree(int $parent_id = 0, array $config = [], array $order_by = []) {
60 60
 
61
-			if (!(static::$nesting && ($parent_id >= 0))) return false;
61
+			if (!(static::$nesting && ($parent_id >= 0))) {
62
+				return false;
63
+			}
62 64
 
63 65
 			# Select entities
64 66
 
65 67
 			$query = $this->getSelectQuery($parent_id, $config, $order_by);
66 68
 
67
-			if (!(DB::send($query) && DB::getLast()->status)) return false;
69
+			if (!(DB::send($query) && DB::getLast()->status)) {
70
+				return false;
71
+			}
68 72
 
69 73
 			# Process results
70 74
 
@@ -88,13 +92,17 @@  discard block
 block discarded – undo
88 92
 
89 93
 		public function subtreeCount(int $parent_id = 0) {
90 94
 
91
-			if (!(static::$nesting && ($parent_id >= 0))) return false;
95
+			if (!(static::$nesting && ($parent_id >= 0))) {
96
+				return false;
97
+			}
92 98
 
93 99
 			# Get count
94 100
 
95 101
 			$query = $this->getCountQuery($parent_id);
96 102
 
97
-			if (!(DB::send($query) && DB::getLast()->status)) return false;
103
+			if (!(DB::send($query) && DB::getLast()->status)) {
104
+				return false;
105
+			}
98 106
 
99 107
 			# ------------------------
100 108
 
@@ -105,13 +113,17 @@  discard block
 block discarded – undo
105 113
 
106 114
 		public function subtreeDepth(int $parent_id = 0) {
107 115
 
108
-			if (!(static::$nesting && ($parent_id >= 0))) return false;
116
+			if (!(static::$nesting && ($parent_id >= 0))) {
117
+				return false;
118
+			}
109 119
 
110 120
 			# Get depth
111 121
 
112 122
 			$query = $this->getDepthQuery($parent_id);
113 123
 
114
-			if (!(DB::send($query) && DB::getLast()->status)) return false;
124
+			if (!(DB::send($query) && DB::getLast()->status)) {
125
+				return false;
126
+			}
115 127
 
116 128
 			# ------------------------
117 129
 
@@ -122,7 +134,9 @@  discard block
 block discarded – undo
122 134
 
123 135
 		public function path(int $parent_id = 0) {
124 136
 
125
-			if (!(static::$nesting && ($parent_id >= 0))) return false;
137
+			if (!(static::$nesting && ($parent_id >= 0))) {
138
+				return false;
139
+			}
126 140
 
127 141
 			# Process query
128 142
 
@@ -134,13 +148,17 @@  discard block
 block discarded – undo
134 148
 
135 149
 			# Select path
136 150
 
137
-			if (!(DB::send($query) && DB::getLast()->status)) return false;
151
+			if (!(DB::send($query) && DB::getLast()->status)) {
152
+				return false;
153
+			}
138 154
 
139 155
 			# Process results
140 156
 
141 157
 			$path = [];
142 158
 
143
-			while (null !== ($data = DB::getLast()->getRow())) $path[] = Entitizer::dataset(static::$table, $data)->data();
159
+			while (null !== ($data = DB::getLast()->getRow())) {
160
+				$path[] = Entitizer::dataset(static::$table, $data)->data();
161
+			}
144 162
 
145 163
 			# ------------------------
146 164
 
Please login to merge, or discard this patch.
engine/System/Classes/Modules/Entitizer/Utils/Definition/Group/Indexes.php 1 patch
Braces   +3 added lines, -1 removed lines patch added patch discarded remove patch
@@ -19,7 +19,9 @@
 block discarded – undo
19 19
 
20 20
 		public function add(string $name, string $type = null) {
21 21
 
22
-			if ((false === $this->definition->param($name)) || isset($this->list[$name])) return;
22
+			if ((false === $this->definition->param($name)) || isset($this->list[$name])) {
23
+				return;
24
+			}
23 25
 
24 26
 			$this->list[$name] = new Definition\Item\Index($name, $type);
25 27
 		}
Please login to merge, or discard this patch.
engine/System/Classes/Modules/Entitizer/Utils/Definition/Group/Foreigns.php 1 patch
Braces   +3 added lines, -1 removed lines patch added patch discarded remove patch
@@ -10,7 +10,9 @@
 block discarded – undo
10 10
 
11 11
 		public function add(string $name, string $table, string $field, string $delete = null, string $update = null) {
12 12
 
13
-			if ((false === $this->definition->param($name)) || isset($this->list[$name])) return;
13
+			if ((false === $this->definition->param($name)) || isset($this->list[$name])) {
14
+				return;
15
+			}
14 16
 
15 17
 			$this->list[$name] = new Definition\Item\Foreign($name, $table, $field, $delete, $update);
16 18
 		}
Please login to merge, or discard this patch.
www/engine/System/Classes/Modules/Entitizer/Utils/Factory.php 1 patch
Braces   +6 added lines, -2 removed lines patch added patch discarded remove patch
@@ -12,9 +12,13 @@
 block discarded – undo
12 12
 
13 13
 		public static function get(string $table) {
14 14
 
15
-			if (!isset(static::$classes[$table])) throw new Exception\General(static::$error_message);
15
+			if (!isset(static::$classes[$table])) {
16
+				throw new Exception\General(static::$error_message);
17
+			}
16 18
 
17
-			if (!isset(static::$cache[$table])) static::$cache[$table] = new static::$classes[$table];
19
+			if (!isset(static::$cache[$table])) {
20
+				static::$cache[$table] = new static::$classes[$table];
21
+			}
18 22
 
19 23
 			# ------------------------
20 24
 
Please login to merge, or discard this patch.