@@ -131,7 +131,7 @@ |
||
131 | 131 | if (\PEAR::isError($mail)) |
132 | 132 | { |
133 | 133 | $this->error( |
134 | - $mail->getCode(), $mail->getMessage() |
|
134 | + $mail->getCode(), $mail->getMessage() |
|
135 | 135 | ); |
136 | 136 | |
137 | 137 | return false; |
@@ -114,7 +114,7 @@ discard block |
||
114 | 114 | */ |
115 | 115 | public function send($from, $to, $subject, $body) |
116 | 116 | { |
117 | - $headers = array ( |
|
117 | + $headers = array( |
|
118 | 118 | 'From' => $from, |
119 | 119 | 'To' => $to, |
120 | 120 | 'Subject' => $subject, |
@@ -123,7 +123,7 @@ discard block |
||
123 | 123 | |
124 | 124 | $smtp = \Mail::factory( |
125 | 125 | 'smtp', |
126 | - array ('host' => $this->host, 'auth' => false) |
|
126 | + array('host' => $this->host, 'auth' => false) |
|
127 | 127 | ); |
128 | 128 | |
129 | 129 | $mail = $smtp->send($to, $headers, $body); |
@@ -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 | /** |
@@ -22,10 +22,10 @@ |
||
22 | 22 | * |
23 | 23 | * @var integer |
24 | 24 | */ |
25 | - const FILE_PERMISSION_DENIED = 1; |
|
26 | - const FILE_NOT_FOUND = 2; |
|
27 | - const FILE_EXISTS = 3; |
|
28 | - const NOT_DIRECTORY = 4; |
|
25 | + const FILE_PERMISSION_DENIED = 1; |
|
26 | + const FILE_NOT_FOUND = 2; |
|
27 | + const FILE_EXISTS = 3; |
|
28 | + const NOT_DIRECTORY = 4; |
|
29 | 29 | |
30 | 30 | /** |
31 | 31 | * Common JSON errors |
@@ -58,7 +58,7 @@ |
||
58 | 58 | |
59 | 59 | $constName = null; |
60 | 60 | |
61 | - foreach ($constants as $name => $value ) |
|
61 | + foreach ($constants as $name => $value) |
|
62 | 62 | { |
63 | 63 | if ($value == $code) |
64 | 64 | { |
@@ -67,12 +67,13 @@ |
||
67 | 67 | */ |
68 | 68 | protected function error($code, $message = null) |
69 | 69 | { |
70 | - if (!array_key_exists($code, $this->errors)) |
|
71 | - $this->errors[$code] = (array_key_exists($code, $this->standardErrors)) |
|
70 | + if (!array_key_exists($code, $this->errors)) { |
|
71 | + $this->errors[$code] = (array_key_exists($code, $this->standardErrors)) |
|
72 | 72 | ? |
73 | 73 | is_null($message) |
74 | 74 | ? $this->standardErrors[$code] |
75 | 75 | : preg_replace('/%[a-zA-Z]*%/', $message, $this->standardErrors[$code]) |
76 | 76 | : $message; |
77 | + } |
|
77 | 78 | } |
78 | 79 | } |
79 | 80 | \ No newline at end of file |
@@ -70,8 +70,9 @@ |
||
70 | 70 | { |
71 | 71 | $parameters = $this->getParams(); |
72 | 72 | |
73 | - if (array_key_exists($param, $parameters)) |
|
74 | - return true; |
|
73 | + if (array_key_exists($param, $parameters)) { |
|
74 | + return true; |
|
75 | + } |
|
75 | 76 | |
76 | 77 | return false; |
77 | 78 | } |
@@ -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 | } |
@@ -132,14 +132,15 @@ discard block |
||
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 | 139 | spl_autoload_register($module . "\Module::loader"); |
139 | 140 | } |
141 | + } else { |
|
142 | + throw new \RuntimeException("The application must have at least one module"); |
|
140 | 143 | } |
141 | - else |
|
142 | - throw new \RuntimeException("The application must have at least one module"); |
|
143 | 144 | } |
144 | 145 | |
145 | 146 | /** |
@@ -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 |