@@ -59,8 +59,11 @@ discard block |
||
59 | 59 | public function registerEngines(array $engines = array()) |
60 | 60 | { |
61 | 61 | foreach ($engines as $key => $value) { |
62 | - if ($value instanceof \Closure) $this->_engines[$key] = $value(); |
|
63 | - else $this->_engines[$key] = $value; |
|
62 | + if ($value instanceof \Closure) { |
|
63 | + $this->_engines[$key] = $value(); |
|
64 | + } else { |
|
65 | + $this->_engines[$key] = $value; |
|
66 | + } |
|
64 | 67 | } |
65 | 68 | } |
66 | 69 | |
@@ -73,7 +76,9 @@ discard block |
||
73 | 76 | */ |
74 | 77 | public function render($path, $data = false) |
75 | 78 | { |
76 | - if ($data === false) $data = $this->data; |
|
79 | + if ($data === false) { |
|
80 | + $data = $this->data; |
|
81 | + } |
|
77 | 82 | |
78 | 83 | // Application view |
79 | 84 | $appfile = APPPATH . 'Views' . DIRECTORY_SEPARATOR . THEME . DIRECTORY_SEPARATOR . $path . '.php'; |
@@ -33,7 +33,7 @@ discard block |
||
33 | 33 | { |
34 | 34 | // The URI should be considered literal except for keys and optional parts |
35 | 35 | // Escape everything preg_quote would escape except for : ( ) < > |
36 | - $expression = preg_replace('#'.Route::REGEX_ESCAPE.'#', '\\\\$0', $uri); |
|
36 | + $expression = preg_replace('#' . Route::REGEX_ESCAPE . '#', '\\\\$0', $uri); |
|
37 | 37 | |
38 | 38 | if (strpos($expression, '(') !== FALSE) |
39 | 39 | { |
@@ -42,14 +42,14 @@ discard block |
||
42 | 42 | } |
43 | 43 | |
44 | 44 | // Insert default regex for keys |
45 | - $expression = str_replace(array('<', '>'), array('(?P<', '>'.Route::REGEX_SEGMENT.')'), $expression); |
|
45 | + $expression = str_replace(array('<', '>'), array('(?P<', '>' . Route::REGEX_SEGMENT . ')'), $expression); |
|
46 | 46 | |
47 | 47 | if ($regex) |
48 | 48 | { |
49 | 49 | $search = $replace = array(); |
50 | 50 | foreach ($regex as $key => $value) |
51 | 51 | { |
52 | - $search[] = "<$key>".Route::REGEX_SEGMENT; |
|
52 | + $search[] = "<$key>" . Route::REGEX_SEGMENT; |
|
53 | 53 | $replace[] = "<$key>$value"; |
54 | 54 | } |
55 | 55 | |
@@ -57,7 +57,7 @@ discard block |
||
57 | 57 | $expression = str_replace($search, $replace, $expression); |
58 | 58 | } |
59 | 59 | |
60 | - return '#^'.$expression.'$#uD'; |
|
60 | + return '#^' . $expression . '$#uD'; |
|
61 | 61 | } |
62 | 62 | |
63 | 63 | /** |
@@ -104,12 +104,12 @@ discard block |
||
104 | 104 | return; |
105 | 105 | } |
106 | 106 | |
107 | - if ( ! empty($uri)) |
|
107 | + if (!empty($uri)) |
|
108 | 108 | { |
109 | 109 | $this->_uri = $uri; |
110 | 110 | } |
111 | 111 | |
112 | - if ( ! empty($regex)) |
|
112 | + if (!empty($regex)) |
|
113 | 113 | { |
114 | 114 | $this->_regex = $regex; |
115 | 115 | } |
@@ -147,7 +147,7 @@ discard block |
||
147 | 147 | $uri = trim($request->uri(), '/'); |
148 | 148 | // $uri = $request->uri(); |
149 | 149 | |
150 | - if ( ! preg_match($this->_route_regex, $uri, $matches)) |
|
150 | + if (!preg_match($this->_route_regex, $uri, $matches)) |
|
151 | 151 | return FALSE; |
152 | 152 | |
153 | 153 | $params = array(); |
@@ -166,20 +166,20 @@ discard block |
||
166 | 166 | |
167 | 167 | foreach ($this->_defaults as $key => $value) |
168 | 168 | { |
169 | - if ( ! isset($params[$key]) OR $params[$key] === '') |
|
169 | + if (!isset($params[$key]) OR $params[$key] === '') |
|
170 | 170 | { |
171 | 171 | // Set default values for any key that was not matched |
172 | 172 | $params[$key] = $value; |
173 | 173 | } |
174 | 174 | } |
175 | 175 | |
176 | - if ( ! empty($params['controller'])) |
|
176 | + if (!empty($params['controller'])) |
|
177 | 177 | { |
178 | 178 | // PSR-0: Replace underscores with spaces, run ucwords, then replace underscore |
179 | 179 | $params['controller'] = str_replace(' ', '_', ucwords(str_replace('_', ' ', $params['controller']))); |
180 | 180 | } |
181 | 181 | |
182 | - if ( ! empty($params['directory'])) |
|
182 | + if (!empty($params['directory'])) |
|
183 | 183 | { |
184 | 184 | // PSR-0: Replace underscores with spaces, run ucwords, then replace underscore |
185 | 185 | $params['directory'] = str_replace(' ', '_', ucwords(str_replace('_', ' ', $params['directory']))); |
@@ -210,12 +210,12 @@ discard block |
||
210 | 210 | * @param boolean $required Whether or not parameters are required (initially) |
211 | 211 | * @return array Tuple of the compiled portion and whether or not it contained specified parameters |
212 | 212 | */ |
213 | - $compile = function ($portion, $required) use (&$compile, $defaults, $params) |
|
213 | + $compile = function($portion, $required) use (&$compile, $defaults, $params) |
|
214 | 214 | { |
215 | 215 | $missing = array(); |
216 | 216 | |
217 | - $pattern = '#(?:'.Route::REGEX_KEY.'|'.Route::REGEX_GROUP.')#'; |
|
218 | - $result = preg_replace_callback($pattern, function ($matches) use (&$compile, $defaults, &$missing, $params, &$required) |
|
217 | + $pattern = '#(?:' . Route::REGEX_KEY . '|' . Route::REGEX_GROUP . ')#'; |
|
218 | + $result = preg_replace_callback($pattern, function($matches) use (&$compile, $defaults, &$missing, $params, &$required) |
|
219 | 219 | { |
220 | 220 | if ($matches[0][0] === '<') |
221 | 221 | { |
@@ -226,7 +226,7 @@ discard block |
||
226 | 226 | { |
227 | 227 | // This portion is required when a specified |
228 | 228 | // parameter does not match the default |
229 | - $required = ($required OR ! isset($defaults[$param]) OR $params[$param] !== $defaults[$param]); |
|
229 | + $required = ($required OR !isset($defaults[$param]) OR $params[$param] !== $defaults[$param]); |
|
230 | 230 | |
231 | 231 | // Add specified parameter to this result |
232 | 232 | return $params[$param]; |
@@ -147,8 +147,9 @@ discard block |
||
147 | 147 | $uri = trim($request->uri(), '/'); |
148 | 148 | // $uri = $request->uri(); |
149 | 149 | |
150 | - if ( ! preg_match($this->_route_regex, $uri, $matches)) |
|
151 | - return FALSE; |
|
150 | + if ( ! preg_match($this->_route_regex, $uri, $matches)) { |
|
151 | + return FALSE; |
|
152 | + } |
|
152 | 153 | |
153 | 154 | $params = array(); |
154 | 155 | foreach ($matches as $key => $value) |
@@ -233,13 +234,13 @@ discard block |
||
233 | 234 | } |
234 | 235 | |
235 | 236 | // Add default parameter to this result |
236 | - if (isset($defaults[$param])) |
|
237 | - return $defaults[$param]; |
|
237 | + if (isset($defaults[$param])) { |
|
238 | + return $defaults[$param]; |
|
239 | + } |
|
238 | 240 | |
239 | 241 | // This portion is missing a parameter |
240 | 242 | $missing[] = $param; |
241 | - } |
|
242 | - else |
|
243 | + } else |
|
243 | 244 | { |
244 | 245 | // Group, unwrapped |
245 | 246 | $result = $compile($matches[2], FALSE); |
@@ -3,13 +3,13 @@ |
||
3 | 3 | return [ |
4 | 4 | 'default' => [ |
5 | 5 | 'driver' => 'mysql', |
6 | - 'host' => '127.0.0.1', // optional, default: 127.0.0.1 |
|
7 | - 'port' => '3306', // optional, default: 3306 |
|
6 | + 'host' => '127.0.0.1', // optional, default: 127.0.0.1 |
|
7 | + 'port' => '3306', // optional, default: 3306 |
|
8 | 8 | 'username' => 'admin', |
9 | 9 | 'password' => 'admin_pass', |
10 | 10 | 'dbname' => 'database', |
11 | - 'prefix' => 'prefix_', // optional, default: is empty |
|
12 | - 'collation' => 'utf8_unicode_ci', // optional, default: utf8_unicode_ci |
|
13 | - 'charset' => 'utf8', // optional, default: utf8 |
|
11 | + 'prefix' => 'prefix_', // optional, default: is empty |
|
12 | + 'collation' => 'utf8_unicode_ci', // optional, default: utf8_unicode_ci |
|
13 | + 'charset' => 'utf8', // optional, default: utf8 |
|
14 | 14 | ], |
15 | 15 | ]; |