@@ -39,9 +39,9 @@ |
||
| 39 | 39 | $again = true; |
| 40 | 40 | $new_config[$param . $glue . $key] = $value; |
| 41 | 41 | } |
| 42 | + } else { |
|
| 43 | + $new_config[$param] = $configure; |
|
| 42 | 44 | } |
| 43 | - else |
|
| 44 | - $new_config[$param] = $configure; |
|
| 45 | 45 | } |
| 46 | 46 | |
| 47 | 47 | return (!$again) ? $new_config : self::toUnidimensional($new_config, $glue); |
@@ -60,7 +60,7 @@ |
||
| 60 | 60 | |
| 61 | 61 | if (!empty($string)) |
| 62 | 62 | { |
| 63 | - $data = json_decode($string, true); |
|
| 63 | + $data = json_decode($string, true); |
|
| 64 | 64 | |
| 65 | 65 | # json_encode can return TRUE, FALSE or NULL (http://php.net/manual/en/function.json-decode.php) |
| 66 | 66 | if (is_null($data) || $data === false) |
@@ -76,17 +76,20 @@ |
||
| 76 | 76 | "object" => serialize($exception) |
| 77 | 77 | ]; |
| 78 | 78 | |
| 79 | - if (!function_exists('mb_detect_encoding')) |
|
| 80 | - throw new \RuntimeException("mbstring library is not installed!"); |
|
| 79 | + if (!function_exists('mb_detect_encoding')) { |
|
| 80 | + throw new \RuntimeException("mbstring library is not installed!"); |
|
| 81 | + } |
|
| 81 | 82 | |
| 82 | 83 | /* |
| 83 | 84 | * Encodes to UTF8 all messages. It ensures JSON encoding. |
| 84 | 85 | */ |
| 85 | - if (!mb_detect_encoding($data[$id]["message"], 'UTF-8', true)) |
|
| 86 | - $data[$id]["message"] = utf8_encode($data[$id]["message"]); |
|
| 86 | + if (!mb_detect_encoding($data[$id]["message"], 'UTF-8', true)) { |
|
| 87 | + $data[$id]["message"] = utf8_encode($data[$id]["message"]); |
|
| 88 | + } |
|
| 87 | 89 | |
| 88 | - if (!mb_detect_encoding($data[$id]["object"], 'UTF-8', true)) |
|
| 89 | - $data[$id]["object"] = utf8_decode($data[$id]["object"]); |
|
| 90 | + if (!mb_detect_encoding($data[$id]["object"], 'UTF-8', true)) { |
|
| 91 | + $data[$id]["object"] = utf8_decode($data[$id]["object"]); |
|
| 92 | + } |
|
| 90 | 93 | |
| 91 | 94 | if (($encoded_data = json_encode($data)) === false) |
| 92 | 95 | { |
@@ -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 | } |
@@ -132,8 +132,8 @@ |
||
| 132 | 132 | * This instruction include each module declared in application.config.php |
| 133 | 133 | * Each module has an autoloader to load its classes (controllers and models) |
| 134 | 134 | */ |
| 135 | - if (file_exists("module/".$module."/Module.php")) |
|
| 136 | - include("module/".$module."/Module.php"); |
|
| 135 | + if (file_exists("module/" . $module . "/Module.php")) |
|
| 136 | + include("module/" . $module . "/Module.php"); |
|
| 137 | 137 | |
| 138 | 138 | spl_autoload_register($module . "\Module::loader"); |
| 139 | 139 | } |
@@ -58,8 +58,9 @@ discard block |
||
| 58 | 58 | public function prepare() |
| 59 | 59 | { |
| 60 | 60 | # start sessions |
| 61 | - if (!isset($_SESSION)) |
|
| 62 | - session_start(); |
|
| 61 | + if (!isset($_SESSION)) { |
|
| 62 | + session_start(); |
|
| 63 | + } |
|
| 63 | 64 | } |
| 64 | 65 | |
| 65 | 66 | /** |
@@ -91,8 +92,7 @@ discard block |
||
| 91 | 92 | |
| 92 | 93 | // Best way to view all possible errors |
| 93 | 94 | error_reporting(-1); |
| 94 | - } |
|
| 95 | - else { |
|
| 95 | + } else { |
|
| 96 | 96 | ini_set('display_errors', 0); |
| 97 | 97 | error_reporting(-1); |
| 98 | 98 | } |
@@ -109,10 +109,11 @@ discard block |
||
| 109 | 109 | |
| 110 | 110 | foreach ($app_config_file["router"]["routes"] as $name => $route) |
| 111 | 111 | { |
| 112 | - if ($route instanceof \Zend\Router\Http\RouteInterface) |
|
| 113 | - $this->getRouter()->addZendRoute($name, $route); |
|
| 114 | - else |
|
| 115 | - $this->getRouter()->addRoute($route); |
|
| 112 | + if ($route instanceof \Zend\Router\Http\RouteInterface) { |
|
| 113 | + $this->getRouter()->addZendRoute($name, $route); |
|
| 114 | + } else { |
|
| 115 | + $this->getRouter()->addRoute($route); |
|
| 116 | + } |
|
| 116 | 117 | } |
| 117 | 118 | } |
| 118 | 119 | |
@@ -146,14 +147,15 @@ discard block |
||
| 146 | 147 | * This instruction include each module declared in application.config.php |
| 147 | 148 | * Each module has an autoloader to load its classes (controllers and models) |
| 148 | 149 | */ |
| 149 | - if (file_exists("module/".$module."/Module.php")) |
|
| 150 | - include("module/".$module."/Module.php"); |
|
| 150 | + if (file_exists("module/".$module."/Module.php")) { |
|
| 151 | + include("module/".$module."/Module.php"); |
|
| 152 | + } |
|
| 151 | 153 | |
| 152 | 154 | spl_autoload_register($module . "\Module::loader"); |
| 153 | 155 | } |
| 156 | + } else { |
|
| 157 | + throw new \RuntimeException("The application must have at least one module"); |
|
| 154 | 158 | } |
| 155 | - else |
|
| 156 | - throw new \RuntimeException("The application must have at least one module"); |
|
| 157 | 159 | } |
| 158 | 160 | |
| 159 | 161 | /** |
@@ -175,8 +177,9 @@ discard block |
||
| 175 | 177 | $uri .= !empty($controller) ? '/' . $controller : ""; |
| 176 | 178 | $uri .= !empty($view) ? '/' . $view : ""; |
| 177 | 179 | |
| 178 | - if (empty($uri)) |
|
| 179 | - $uri = "/"; |
|
| 180 | + if (empty($uri)) { |
|
| 181 | + $uri = "/"; |
|
| 182 | + } |
|
| 180 | 183 | |
| 181 | 184 | $request->setUri($uri); |
| 182 | 185 | |
@@ -191,9 +194,9 @@ discard block |
||
| 191 | 194 | $view = $params["action"]; |
| 192 | 195 | |
| 193 | 196 | $this->router->setIdentifiers($module, $controller, $view); |
| 197 | + } else { |
|
| 198 | + $this->router->setIdentifiers($module, $controller, $view); |
|
| 194 | 199 | } |
| 195 | - else |
|
| 196 | - $this->router->setIdentifiers($module, $controller, $view); |
|
| 197 | 200 | |
| 198 | 201 | $this->router->run(); |
| 199 | 202 | } |
@@ -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 |
@@ -168,7 +168,7 @@ |
||
| 168 | 168 | if ($_SERVER['REQUEST_METHOD'] != 'JSON') |
| 169 | 169 | throw new \LogicException("Request method is not JSON"); |
| 170 | 170 | |
| 171 | - $input = file_get_contents('php://input'); |
|
| 171 | + $input = file_get_contents('php://input'); |
|
| 172 | 172 | $array = explode("&", $input); |
| 173 | 173 | |
| 174 | 174 | $result = array(); |
@@ -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"]); |
@@ -164,8 +164,8 @@ discard block |
||
| 164 | 164 | { |
| 165 | 165 | foreach ($params as $param => $value) |
| 166 | 166 | { |
| 167 | - if (property_exists(__CLASS__, strtolower($param)) && method_exists($this, 'set'.$param)) |
|
| 168 | - $this->{'set'.$param}($value); |
|
| 167 | + if (property_exists(__CLASS__, strtolower($param)) && method_exists($this, 'set' . $param)) |
|
| 168 | + $this->{'set' . $param}($value); |
|
| 169 | 169 | } |
| 170 | 170 | } |
| 171 | 171 | |
@@ -185,9 +185,9 @@ discard block |
||
| 185 | 185 | |
| 186 | 186 | if ($controller->getShowView()) |
| 187 | 187 | { |
| 188 | - $view = 'module/' . $controller->getModule()->getModuleName() . |
|
| 189 | - '/source/view/'. basename(str_replace('\\','/',get_class($controller))) . |
|
| 190 | - '/' . $controller->getMethod() . '.phtml'; |
|
| 188 | + $view = 'module/' . $controller->getModule()->getModuleName() . |
|
| 189 | + '/source/view/' . basename(str_replace('\\', '/', get_class($controller))) . |
|
| 190 | + '/' . $controller->getMethod() . '.phtml'; |
|
| 191 | 191 | |
| 192 | 192 | $this->view = $view; |
| 193 | 193 | } |
@@ -162,8 +162,9 @@ discard block |
||
| 162 | 162 | { |
| 163 | 163 | $config = $module->getConfig(); |
| 164 | 164 | |
| 165 | - if (!array_key_exists($view, $config["view_manager"]["view_map"]) || !file_exists($config["view_manager"]["view_map"][$view])) |
|
| 166 | - throw new Exception\ViewNotFoundException("The 'view' template " . $view . " does not exists"); |
|
| 165 | + if (!array_key_exists($view, $config["view_manager"]["view_map"]) || !file_exists($config["view_manager"]["view_map"][$view])) { |
|
| 166 | + throw new Exception\ViewNotFoundException("The 'view' template " . $view . " does not exists"); |
|
| 167 | + } |
|
| 167 | 168 | |
| 168 | 169 | $this->view = $config["view_manager"]["view_map"][$view]; |
| 169 | 170 | } |
@@ -193,8 +194,9 @@ discard block |
||
| 193 | 194 | { |
| 194 | 195 | foreach ($params as $param => $value) |
| 195 | 196 | { |
| 196 | - if (property_exists(__CLASS__, strtolower($param)) && method_exists($this, 'set'.$param)) |
|
| 197 | - $this->{'set'.$param}($value); |
|
| 197 | + if (property_exists(__CLASS__, strtolower($param)) && method_exists($this, 'set'.$param)) { |
|
| 198 | + $this->{'set'.$param}($value); |
|
| 199 | + } |
|
| 198 | 200 | } |
| 199 | 201 | } |
| 200 | 202 | |
@@ -223,25 +225,28 @@ discard block |
||
| 223 | 225 | |
| 224 | 226 | if ($controller->getTerminal()) |
| 225 | 227 | { |
| 226 | - if (file_exists($view)) |
|
| 227 | - include $view; |
|
| 228 | - } |
|
| 229 | - else |
|
| 228 | + if (file_exists($view)) { |
|
| 229 | + include $view; |
|
| 230 | + } |
|
| 231 | + } else |
|
| 230 | 232 | { |
| 231 | - if (!is_null($this->view) && !file_exists($this->view)) |
|
| 232 | - throw new Exception\ViewNotFoundException("The 'view' template " . $this->view . " does not exists"); |
|
| 233 | + if (!is_null($this->view) && !file_exists($this->view)) { |
|
| 234 | + throw new Exception\ViewNotFoundException("The 'view' template " . $this->view . " does not exists"); |
|
| 235 | + } |
|
| 233 | 236 | |
| 234 | 237 | $config = $controller->getModule()->getConfig(); |
| 235 | 238 | |
| 236 | 239 | $layout = $controller->getLayout(); |
| 237 | 240 | |
| 238 | - if (!array_key_exists($controller->getLayout(), $config["view_manager"]["template_map"])) |
|
| 239 | - throw new Exception\PageNotFoundException("The 'template' " . $layout . " was not defined in module.config.php"); |
|
| 241 | + if (!array_key_exists($controller->getLayout(), $config["view_manager"]["template_map"])) { |
|
| 242 | + throw new Exception\PageNotFoundException("The 'template' " . $layout . " was not defined in module.config.php"); |
|
| 243 | + } |
|
| 240 | 244 | |
| 241 | 245 | $template = $config["view_manager"]["template_map"][$controller->getLayout()]; |
| 242 | 246 | |
| 243 | - if (!file_exists($template)) |
|
| 244 | - throw new Exception\PageNotFoundException("The 'template' " . $template . " does not exists"); |
|
| 247 | + if (!file_exists($template)) { |
|
| 248 | + throw new Exception\PageNotFoundException("The 'template' " . $template . " does not exists"); |
|
| 249 | + } |
|
| 245 | 250 | |
| 246 | 251 | include $template; |
| 247 | 252 | } |
@@ -268,8 +273,9 @@ discard block |
||
| 268 | 273 | */ |
| 269 | 274 | public function content() |
| 270 | 275 | { |
| 271 | - if (!file_exists($this->view)) |
|
| 272 | - throw new Exception\ViewNotFoundException("The 'view' template " . $this->view . " does not exists"); |
|
| 276 | + if (!file_exists($this->view)) { |
|
| 277 | + throw new Exception\ViewNotFoundException("The 'view' template " . $this->view . " does not exists"); |
|
| 278 | + } |
|
| 273 | 279 | |
| 274 | 280 | include $this->view; |
| 275 | 281 | } |
@@ -298,8 +298,8 @@ |
||
| 298 | 298 | { |
| 299 | 299 | foreach ($options as $option => $value) |
| 300 | 300 | { |
| 301 | - if (property_exists(__CLASS__, strtolower($option)) && method_exists($this, 'set'.$option)) |
|
| 302 | - $this->{'set'.$option}($value); |
|
| 301 | + if (property_exists(__CLASS__, strtolower($option)) && method_exists($this, 'set' . $option)) |
|
| 302 | + $this->{'set' . $option}($value); |
|
| 303 | 303 | } |
| 304 | 304 | } |
| 305 | 305 | |
@@ -216,8 +216,9 @@ discard block |
||
| 216 | 216 | */ |
| 217 | 217 | public function getArrayResult() |
| 218 | 218 | { |
| 219 | - if (!empty($this->arrayResult)) |
|
| 220 | - return $this->arrayResult; |
|
| 219 | + if (!empty($this->arrayResult)) { |
|
| 220 | + return $this->arrayResult; |
|
| 221 | + } |
|
| 221 | 222 | |
| 222 | 223 | return $this->toArray(); |
| 223 | 224 | } |
@@ -313,8 +314,9 @@ discard block |
||
| 313 | 314 | */ |
| 314 | 315 | public function autocommit($value) |
| 315 | 316 | { |
| 316 | - if ($this->transac_mode) |
|
| 317 | - throw new \LogicException("You cannot change autocommit behavior during a transaction"); |
|
| 317 | + if ($this->transac_mode) { |
|
| 318 | + throw new \LogicException("You cannot change autocommit behavior during a transaction"); |
|
| 319 | + } |
|
| 318 | 320 | |
| 319 | 321 | $this->autocommit = $value; |
| 320 | 322 | } |
@@ -330,8 +332,9 @@ discard block |
||
| 330 | 332 | { |
| 331 | 333 | foreach ($options as $option => $value) |
| 332 | 334 | { |
| 333 | - if (property_exists(__CLASS__, strtolower($option)) && method_exists($this, 'set'.$option)) |
|
| 334 | - $this->{'set'.$option}($value); |
|
| 335 | + if (property_exists(__CLASS__, strtolower($option)) && method_exists($this, 'set'.$option)) { |
|
| 336 | + $this->{'set'.$option}($value); |
|
| 337 | + } |
|
| 335 | 338 | } |
| 336 | 339 | } |
| 337 | 340 | |
@@ -375,8 +378,9 @@ discard block |
||
| 375 | 378 | */ |
| 376 | 379 | public function reconnect() |
| 377 | 380 | { |
| 378 | - if (!$this->isConnected()) |
|
| 379 | - throw new \LogicException("Connection was not established"); |
|
| 381 | + if (!$this->isConnected()) { |
|
| 382 | + throw new \LogicException("Connection was not established"); |
|
| 383 | + } |
|
| 380 | 384 | |
| 381 | 385 | $this->disconnect(); |
| 382 | 386 | return $this->connect(); |
@@ -405,8 +409,9 @@ discard block |
||
| 405 | 409 | */ |
| 406 | 410 | public function disconnect() |
| 407 | 411 | { |
| 408 | - if (!$this->isConnected()) |
|
| 409 | - throw new \LogicException("Connection was not established"); |
|
| 412 | + if (!$this->isConnected()) { |
|
| 413 | + throw new \LogicException("Connection was not established"); |
|
| 414 | + } |
|
| 410 | 415 | } |
| 411 | 416 | |
| 412 | 417 | /** |
@@ -418,11 +423,13 @@ discard block |
||
| 418 | 423 | */ |
| 419 | 424 | public function beginTransaction() |
| 420 | 425 | { |
| 421 | - if (!$this->isConnected()) |
|
| 422 | - $this->connect(); |
|
| 426 | + if (!$this->isConnected()) { |
|
| 427 | + $this->connect(); |
|
| 428 | + } |
|
| 423 | 429 | |
| 424 | - if ($this->transac_mode) |
|
| 425 | - throw new \LogicException($this->standardErrors[Errno::DB_TRANSACTION_STARTED]); |
|
| 430 | + if ($this->transac_mode) { |
|
| 431 | + throw new \LogicException($this->standardErrors[Errno::DB_TRANSACTION_STARTED]); |
|
| 432 | + } |
|
| 426 | 433 | |
| 427 | 434 | $this->transac_mode = true; |
| 428 | 435 | } |
@@ -436,16 +443,19 @@ discard block |
||
| 436 | 443 | */ |
| 437 | 444 | public function endTransaction() |
| 438 | 445 | { |
| 439 | - if (!$this->transac_mode) |
|
| 440 | - throw new \LogicException($this->standardErrors[Errno::DB_TRANSACTION_NOT_STARTED]); |
|
| 446 | + if (!$this->transac_mode) { |
|
| 447 | + throw new \LogicException($this->standardErrors[Errno::DB_TRANSACTION_NOT_STARTED]); |
|
| 448 | + } |
|
| 441 | 449 | |
| 442 | - if (is_null($this->transac_result)) |
|
| 443 | - throw new \LogicException($this->standardErrors[Errno::DB_TRANSACTION_EMPTY]); |
|
| 450 | + if (is_null($this->transac_result)) { |
|
| 451 | + throw new \LogicException($this->standardErrors[Errno::DB_TRANSACTION_EMPTY]); |
|
| 452 | + } |
|
| 444 | 453 | |
| 445 | - if ($this->transac_result) |
|
| 446 | - $this->commit(); |
|
| 447 | - else |
|
| 448 | - $this->rollback(); |
|
| 454 | + if ($this->transac_result) { |
|
| 455 | + $this->commit(); |
|
| 456 | + } else { |
|
| 457 | + $this->rollback(); |
|
| 458 | + } |
|
| 449 | 459 | |
| 450 | 460 | $this->result = $this->transac_result; |
| 451 | 461 | |
@@ -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 |