@@ -145,8 +145,9 @@ discard block |
||
145 | 145 | $module = (is_null($this->identifiers["module"]) || empty($this->identifiers["module"])) |
146 | 146 | ? $this->routes["defaults"]["module"] : $this->identifiers["module"]; |
147 | 147 | |
148 | - if (!array_key_exists($module, $this->routes)) |
|
149 | - throw new Exception\ModuleNotFoundException("The key '$module' does not exists in routes!"); |
|
148 | + if (!array_key_exists($module, $this->routes)) { |
|
149 | + throw new Exception\ModuleNotFoundException("The key '$module' does not exists in routes!"); |
|
150 | + } |
|
150 | 151 | |
151 | 152 | $controller = (is_null($this->identifiers["controller"]) || empty($this->identifiers["controller"])) |
152 | 153 | ? $this->routes[$module]["controller"] : $this->identifiers["controller"]; |
@@ -156,10 +157,11 @@ discard block |
||
156 | 157 | |
157 | 158 | $fqn_controller = '\\' . $module . "\Controller\\" . $controller; |
158 | 159 | |
159 | - if (class_exists($fqn_controller)) |
|
160 | - $this->controller = new $fqn_controller($module, $view, $this->basePath); |
|
161 | - else |
|
162 | - throw new Exception\ControllerNotFoundException("The control class '$fqn_controller' does not exists!"); |
|
160 | + if (class_exists($fqn_controller)) { |
|
161 | + $this->controller = new $fqn_controller($module, $view, $this->basePath); |
|
162 | + } else { |
|
163 | + throw new Exception\ControllerNotFoundException("The control class '$fqn_controller' does not exists!"); |
|
164 | + } |
|
163 | 165 | } |
164 | 166 | |
165 | 167 | /** |
@@ -176,8 +178,9 @@ discard block |
||
176 | 178 | $key = array_keys($route); |
177 | 179 | $key = array_shift($key); |
178 | 180 | |
179 | - if (array_key_exists($key, $this->routes)) |
|
180 | - throw new \LogicException("The key '$key' was already defined as route"); |
|
181 | + if (array_key_exists($key, $this->routes)) { |
|
182 | + throw new \LogicException("The key '$key' was already defined as route"); |
|
183 | + } |
|
181 | 184 | |
182 | 185 | $this->routes = array_merge($this->routes, $route); |
183 | 186 | } |
@@ -80,7 +80,8 @@ |
||
80 | 80 | |
81 | 81 | $class = "module/" . $module . "/source/" . implode("/", $nm) . ".php"; |
82 | 82 | |
83 | - if (file_exists($class)) |
|
84 | - include $class; |
|
83 | + if (file_exists($class)) { |
|
84 | + include $class; |
|
85 | + } |
|
85 | 86 | } |
86 | 87 | } |
87 | 88 | \ No newline at end of file |
@@ -85,13 +85,14 @@ discard block |
||
85 | 85 | "Sqlsrv" => "Drone\Db\Driver\SQLServer", |
86 | 86 | ]; |
87 | 87 | |
88 | - if (gettype($connection_identifier) == 'array') |
|
89 | - $connection_array = $connection_identifier; |
|
90 | - else |
|
88 | + if (gettype($connection_identifier) == 'array') { |
|
89 | + $connection_array = $connection_identifier; |
|
90 | + } else |
|
91 | 91 | { |
92 | 92 | # Take connection parameters from configuration file |
93 | - if (!file_exists("config/database.config.php")) |
|
94 | - throw new \RuntimeException("config/data.base.config.php is missing!"); |
|
93 | + if (!file_exists("config/database.config.php")) { |
|
94 | + throw new \RuntimeException("config/data.base.config.php is missing!"); |
|
95 | + } |
|
95 | 96 | |
96 | 97 | $dbsettings = include("config/database.config.php"); |
97 | 98 | $connection_array = $dbsettings[$connection_identifier]; |
@@ -106,8 +107,8 @@ discard block |
||
106 | 107 | |
107 | 108 | $this->driverName = $drv; |
108 | 109 | $this->db = new $driver[$drv]($connection_array); |
110 | + } else { |
|
111 | + throw new \RuntimeException("The Database driver does not exists"); |
|
109 | 112 | } |
110 | - else |
|
111 | - throw new \RuntimeException("The Database driver does not exists"); |
|
112 | 113 | } |
113 | 114 | } |
114 | 115 | \ No newline at end of file |
@@ -77,8 +77,9 @@ |
||
77 | 77 | |
78 | 78 | foreach ($arguments as $key => $arg) |
79 | 79 | { |
80 | - if (is_string($arg)) |
|
81 | - $arguments[$key] = "'$arg'"; |
|
80 | + if (is_string($arg)) { |
|
81 | + $arguments[$key] = "'$arg'"; |
|
82 | + } |
|
82 | 83 | } |
83 | 84 | |
84 | 85 | $arguments = implode(", ", array_values($arguments)); |
@@ -73,7 +73,8 @@ |
||
73 | 73 | { |
74 | 74 | $this->currentDriverIdentifier = $connection_identifier; |
75 | 75 | |
76 | - if (!isset(self::$drivers[$connection_identifier])) |
|
77 | - self::$drivers[$connection_identifier] = new DriverAdapter($connection_identifier, $auto_connect); |
|
76 | + if (!isset(self::$drivers[$connection_identifier])) { |
|
77 | + self::$drivers[$connection_identifier] = new DriverAdapter($connection_identifier, $auto_connect); |
|
78 | + } |
|
78 | 79 | } |
79 | 80 | } |
80 | 81 | \ No newline at end of file |
@@ -58,8 +58,9 @@ discard block |
||
58 | 58 | { |
59 | 59 | $result = $this->tableGateway->select($where); |
60 | 60 | |
61 | - if (!count($result)) |
|
62 | - return $result; |
|
61 | + if (!count($result)) { |
|
62 | + return $result; |
|
63 | + } |
|
63 | 64 | |
64 | 65 | $array_result = []; |
65 | 66 | |
@@ -69,8 +70,9 @@ discard block |
||
69 | 70 | |
70 | 71 | foreach ($row as $key => $value) |
71 | 72 | { |
72 | - if (is_string($key)) |
|
73 | - $filtered_array[$key] = $value; |
|
73 | + if (is_string($key)) { |
|
74 | + $filtered_array[$key] = $value; |
|
75 | + } |
|
74 | 76 | } |
75 | 77 | |
76 | 78 | $user_entity = get_class($this->tableGateway->getEntity()); |
@@ -94,10 +96,11 @@ discard block |
||
94 | 96 | */ |
95 | 97 | public function insert($entity) |
96 | 98 | { |
97 | - if ($entity instanceof Entity) |
|
98 | - $entity = get_object_vars($entity); |
|
99 | - else if (!is_array($entity)) |
|
100 | - throw new \InvalidArgumentException("Invalid type given. Drone\Db\Entity or Array expected"); |
|
99 | + if ($entity instanceof Entity) { |
|
100 | + $entity = get_object_vars($entity); |
|
101 | + } else if (!is_array($entity)) { |
|
102 | + throw new \InvalidArgumentException("Invalid type given. Drone\Db\Entity or Array expected"); |
|
103 | + } |
|
101 | 104 | |
102 | 105 | $this->parseEntity($entity); |
103 | 106 | |
@@ -126,14 +129,15 @@ discard block |
||
126 | 129 | |
127 | 130 | foreach ($entity as $key => $value) |
128 | 131 | { |
129 | - if (in_array($key, $changedFields)) |
|
130 | - $fieldsToModify[$key] = $value; |
|
132 | + if (in_array($key, $changedFields)) { |
|
133 | + $fieldsToModify[$key] = $value; |
|
134 | + } |
|
131 | 135 | } |
132 | 136 | |
133 | 137 | $entity = $fieldsToModify; |
138 | + } else if (!is_array($entity)) { |
|
139 | + throw new \InvalidArgumentException("Invalid type given. Drone\Db\Entity or Array expected"); |
|
134 | 140 | } |
135 | - else if (!is_array($entity)) |
|
136 | - throw new \InvalidArgumentException("Invalid type given. Drone\Db\Entity or Array expected"); |
|
137 | 141 | |
138 | 142 | $this->parseEntity($entity); |
139 | 143 | |
@@ -152,10 +156,11 @@ discard block |
||
152 | 156 | */ |
153 | 157 | public function delete($entity) |
154 | 158 | { |
155 | - if ($entity instanceof Entity) |
|
156 | - $entity = get_object_vars($entity); |
|
157 | - else if (!is_array($entity)) |
|
158 | - throw new \InvalidArgumentException("Invalid type given. Drone\Db\Entity or Array expected"); |
|
159 | + if ($entity instanceof Entity) { |
|
160 | + $entity = get_object_vars($entity); |
|
161 | + } else if (!is_array($entity)) { |
|
162 | + throw new \InvalidArgumentException("Invalid type given. Drone\Db\Entity or Array expected"); |
|
163 | + } |
|
159 | 164 | |
160 | 165 | return $this->tableGateway->delete($entity); |
161 | 166 | } |
@@ -133,8 +133,9 @@ discard block |
||
133 | 133 | { |
134 | 134 | $config = $module->getConfig(); |
135 | 135 | |
136 | - if (!array_key_exists($view, $config["view_manager"]["view_map"]) || !file_exists($config["view_manager"]["view_map"][$view])) |
|
137 | - throw new Exception\ViewNotFoundException("The 'view' template " . $view . " does not exists"); |
|
136 | + if (!array_key_exists($view, $config["view_manager"]["view_map"]) || !file_exists($config["view_manager"]["view_map"][$view])) { |
|
137 | + throw new Exception\ViewNotFoundException("The 'view' template " . $view . " does not exists"); |
|
138 | + } |
|
138 | 139 | |
139 | 140 | $this->view = $config["view_manager"]["view_map"][$view]; |
140 | 141 | } |
@@ -164,8 +165,9 @@ discard block |
||
164 | 165 | { |
165 | 166 | foreach ($params as $param => $value) |
166 | 167 | { |
167 | - if (property_exists(__CLASS__, strtolower($param)) && method_exists($this, 'set'.$param)) |
|
168 | - $this->{'set'.$param}($value); |
|
168 | + if (property_exists(__CLASS__, strtolower($param)) && method_exists($this, 'set'.$param)) { |
|
169 | + $this->{'set'.$param}($value); |
|
170 | + } |
|
169 | 171 | } |
170 | 172 | } |
171 | 173 | |
@@ -194,23 +196,26 @@ discard block |
||
194 | 196 | |
195 | 197 | if ($controller->getTerminal()) |
196 | 198 | { |
197 | - if (file_exists($view)) |
|
198 | - include $view; |
|
199 | - } |
|
200 | - else |
|
199 | + if (file_exists($view)) { |
|
200 | + include $view; |
|
201 | + } |
|
202 | + } else |
|
201 | 203 | { |
202 | - if (!is_null($this->view) && !file_exists($this->view)) |
|
203 | - throw new Exception\ViewNotFoundException("The 'view' template " . $this->view . " does not exists"); |
|
204 | + if (!is_null($this->view) && !file_exists($this->view)) { |
|
205 | + throw new Exception\ViewNotFoundException("The 'view' template " . $this->view . " does not exists"); |
|
206 | + } |
|
204 | 207 | |
205 | 208 | $config = $controller->getModule()->getConfig(); |
206 | 209 | |
207 | - if (!array_key_exists($controller->getLayout(), $config["view_manager"]["template_map"])) |
|
208 | - throw new Exception\PageNotFoundException("The 'template' " . $template . " was not defined in module.config.php"); |
|
210 | + if (!array_key_exists($controller->getLayout(), $config["view_manager"]["template_map"])) { |
|
211 | + throw new Exception\PageNotFoundException("The 'template' " . $template . " was not defined in module.config.php"); |
|
212 | + } |
|
209 | 213 | |
210 | 214 | $template = $config["view_manager"]["template_map"][$controller->getLayout()]; |
211 | 215 | |
212 | - if (!file_exists($template)) |
|
213 | - throw new Exception\PageNotFoundException("The 'template' " . $template . " does not exists"); |
|
216 | + if (!file_exists($template)) { |
|
217 | + throw new Exception\PageNotFoundException("The 'template' " . $template . " does not exists"); |
|
218 | + } |
|
214 | 219 | |
215 | 220 | include $template; |
216 | 221 | } |
@@ -237,8 +242,9 @@ discard block |
||
237 | 242 | */ |
238 | 243 | public function content() |
239 | 244 | { |
240 | - if (!file_exists($this->view)) |
|
241 | - throw new Exception\ViewNotFoundException("The 'view' template " . $this->view . " does not exists"); |
|
245 | + if (!file_exists($this->view)) { |
|
246 | + throw new Exception\ViewNotFoundException("The 'view' template " . $this->view . " does not exists"); |
|
247 | + } |
|
242 | 248 | |
243 | 249 | include $this->view; |
244 | 250 | } |
@@ -150,8 +150,9 @@ discard block |
||
150 | 150 | */ |
151 | 151 | public function getPost() |
152 | 152 | { |
153 | - if ($_SERVER['REQUEST_METHOD'] == 'POST' && empty($_POST)) |
|
154 | - $_POST = json_decode(file_get_contents('php://input'), true); |
|
153 | + if ($_SERVER['REQUEST_METHOD'] == 'POST' && empty($_POST)) { |
|
154 | + $_POST = json_decode(file_get_contents('php://input'), true); |
|
155 | + } |
|
155 | 156 | |
156 | 157 | return (array) $_POST; |
157 | 158 | } |
@@ -165,8 +166,9 @@ discard block |
||
165 | 166 | */ |
166 | 167 | public function getJson() |
167 | 168 | { |
168 | - if ($_SERVER['REQUEST_METHOD'] != 'JSON') |
|
169 | - throw new \LogicException("Request method is not JSON"); |
|
169 | + if ($_SERVER['REQUEST_METHOD'] != 'JSON') { |
|
170 | + throw new \LogicException("Request method is not JSON"); |
|
171 | + } |
|
170 | 172 | |
171 | 173 | $input = file_get_contents('php://input'); |
172 | 174 | $array = explode("&", $input); |
@@ -254,8 +256,9 @@ discard block |
||
254 | 256 | $this->module = new $fqn($module, $this); |
255 | 257 | |
256 | 258 | # detects method change inside Module.php |
257 | - if (!is_null($this->getMethod())) |
|
258 | - $method = $this->getMethod(); |
|
259 | + if (!is_null($this->getMethod())) { |
|
260 | + $method = $this->getMethod(); |
|
261 | + } |
|
259 | 262 | |
260 | 263 | if (!is_null($method) && $this->initExecution) |
261 | 264 | { |
@@ -265,8 +268,9 @@ discard block |
||
265 | 268 | |
266 | 269 | $reflection = new \ReflectionMethod($this, $method); |
267 | 270 | |
268 | - if (!$reflection->isPublic()) |
|
269 | - throw new Exception\PageNotFoundException("The method '$method' is not public in the control class '$class'"); |
|
271 | + if (!$reflection->isPublic()) { |
|
272 | + throw new Exception\PageNotFoundException("The method '$method' is not public in the control class '$class'"); |
|
273 | + } |
|
270 | 274 | |
271 | 275 | $this->method = $method; |
272 | 276 | |
@@ -282,8 +286,7 @@ discard block |
||
282 | 286 | $layoutManager = new Layout($layout_params); |
283 | 287 | $layoutManager->fromController($this); |
284 | 288 | } |
285 | - } |
|
286 | - else { |
|
289 | + } else { |
|
287 | 290 | $class = __CLASS__; |
288 | 291 | throw new Exception\PageNotFoundException("The method '$method' doesn't exists in the control class '$class'"); |
289 | 292 | } |
@@ -308,8 +311,9 @@ discard block |
||
308 | 311 | public function isXmlHttpRequest() |
309 | 312 | { |
310 | 313 | # non standard (HTTP_X_REQUESTED_WITH is not a part of PHP) |
311 | - if (isset($_SERVER['HTTP_X_REQUESTED_WITH'])) |
|
312 | - return true; |
|
314 | + if (isset($_SERVER['HTTP_X_REQUESTED_WITH'])) { |
|
315 | + return true; |
|
316 | + } |
|
313 | 317 | return false; |
314 | 318 | } |
315 | 319 | |
@@ -320,8 +324,9 @@ discard block |
||
320 | 324 | */ |
321 | 325 | public function isPost() |
322 | 326 | { |
323 | - if ($_SERVER["REQUEST_METHOD"] == "POST") |
|
324 | - return true; |
|
327 | + if ($_SERVER["REQUEST_METHOD"] == "POST") { |
|
328 | + return true; |
|
329 | + } |
|
325 | 330 | return false; |
326 | 331 | } |
327 | 332 | |
@@ -332,8 +337,9 @@ discard block |
||
332 | 337 | */ |
333 | 338 | public function isGet() |
334 | 339 | { |
335 | - if ($_SERVER["REQUEST_METHOD"] == "GET") |
|
336 | - return true; |
|
340 | + if ($_SERVER["REQUEST_METHOD"] == "GET") { |
|
341 | + return true; |
|
342 | + } |
|
337 | 343 | return false; |
338 | 344 | } |
339 | 345 | |
@@ -357,10 +363,11 @@ discard block |
||
357 | 363 | $i = 1; |
358 | 364 | foreach ($params as $item) |
359 | 365 | { |
360 | - if ($i % 2 != 0) |
|
361 | - $vars[] = $item; |
|
362 | - else |
|
363 | - $values[] = $item; |
|
366 | + if ($i % 2 != 0) { |
|
367 | + $vars[] = $item; |
|
368 | + } else { |
|
369 | + $values[] = $item; |
|
370 | + } |
|
364 | 371 | $i++; |
365 | 372 | } |
366 | 373 | |
@@ -368,10 +375,11 @@ discard block |
||
368 | 375 | |
369 | 376 | for ($i = 0; $i < $vars_count; $i++) |
370 | 377 | { |
371 | - if (array_key_exists($i, $values)) |
|
372 | - $_GET[$vars[$i]] = $values[$i]; |
|
373 | - else |
|
374 | - $_GET[$vars[$i]] = ''; |
|
378 | + if (array_key_exists($i, $values)) { |
|
379 | + $_GET[$vars[$i]] = $values[$i]; |
|
380 | + } else { |
|
381 | + $_GET[$vars[$i]] = ''; |
|
382 | + } |
|
375 | 383 | } |
376 | 384 | |
377 | 385 | unset($_GET["params"]); |
@@ -74,18 +74,21 @@ discard block |
||
74 | 74 | { |
75 | 75 | @include_once 'System.php'; |
76 | 76 | |
77 | - if (!class_exists('System', false)) |
|
78 | - throw new \RuntimeException("PEAR is not installed in your system!"); |
|
77 | + if (!class_exists('System', false)) { |
|
78 | + throw new \RuntimeException("PEAR is not installed in your system!"); |
|
79 | + } |
|
79 | 80 | |
80 | 81 | include_once 'Net/SMTP.php'; |
81 | 82 | |
82 | - if (!class_exists('\Net_SMTP', false)) |
|
83 | - throw new \RuntimeException("PEAR::Net_SMTP is not installed!"); |
|
83 | + if (!class_exists('\Net_SMTP', false)) { |
|
84 | + throw new \RuntimeException("PEAR::Net_SMTP is not installed!"); |
|
85 | + } |
|
84 | 86 | |
85 | 87 | @include_once 'Mail.php'; |
86 | 88 | |
87 | - if (!class_exists('\Mail', false)) |
|
88 | - throw new \RuntimeException("PEAR::Mail is not installed!"); |
|
89 | + if (!class_exists('\Mail', false)) { |
|
90 | + throw new \RuntimeException("PEAR::Mail is not installed!"); |
|
91 | + } |
|
89 | 92 | } |
90 | 93 | |
91 | 94 | /** |
@@ -98,8 +101,9 @@ discard block |
||
98 | 101 | */ |
99 | 102 | protected function error($code, $message = null) |
100 | 103 | { |
101 | - if (!array_key_exists($code, $this->errors)) |
|
102 | - $this->errors[$message] = (is_null($message) && array_key_exists($code, $this->errors)) ? $this->errors[$code] : $message; |
|
104 | + if (!array_key_exists($code, $this->errors)) { |
|
105 | + $this->errors[$message] = (is_null($message) && array_key_exists($code, $this->errors)) ? $this->errors[$code] : $message; |
|
106 | + } |
|
103 | 107 | } |
104 | 108 | |
105 | 109 | /** |