@@ -92,7 +92,7 @@ discard block |
||
92 | 92 | */ |
93 | 93 | public static function init() |
94 | 94 | { |
95 | - self::$ci =& get_instance(); |
|
95 | + self::$ci = & get_instance(); |
|
96 | 96 | } |
97 | 97 | |
98 | 98 | //-------------------------------------------------------------------- |
@@ -105,7 +105,7 @@ discard block |
||
105 | 105 | Parameters: |
106 | 106 | $data - The variable to log. |
107 | 107 | */ |
108 | - public static function log($data=null) |
|
108 | + public static function log($data = null) |
|
109 | 109 | { |
110 | 110 | if ($data !== 0 && empty($data)) |
111 | 111 | { |
@@ -131,7 +131,7 @@ discard block |
||
131 | 131 | $object - The object to store the memory usage of. |
132 | 132 | $name - The name to be displayed in the console. |
133 | 133 | */ |
134 | - public static function logMemory($object=false, $name='PHP') |
|
134 | + public static function logMemory($object = false, $name = 'PHP') |
|
135 | 135 | { |
136 | 136 | $memory = memory_get_usage(); |
137 | 137 | |
@@ -182,15 +182,15 @@ discard block |
||
182 | 182 | // !PRIVATE METHODS |
183 | 183 | //-------------------------------------------------------------------- |
184 | 184 | |
185 | - protected static function addToConsole($log=null, $item=null) |
|
185 | + protected static function addToConsole($log = null, $item = null) |
|
186 | 186 | { |
187 | 187 | if (empty($log) || empty($item)) |
188 | 188 | { |
189 | 189 | return; |
190 | 190 | } |
191 | 191 | |
192 | - self::$logs['console'][] = $item; |
|
193 | - self::$logs[$log] += 1; |
|
192 | + self::$logs['console'][] = $item; |
|
193 | + self::$logs[$log] += 1; |
|
194 | 194 | } |
195 | 195 | |
196 | 196 | //-------------------------------------------------------------------- |
@@ -81,20 +81,20 @@ discard block |
||
81 | 81 | 'view_data' |
82 | 82 | ); |
83 | 83 | |
84 | - protected $_sections = array(); // Stores _compile_x() results |
|
84 | + protected $_sections = array(); // Stores _compile_x() results |
|
85 | 85 | |
86 | - protected $_query_toggle_count = 25; |
|
86 | + protected $_query_toggle_count = 25; |
|
87 | 87 | |
88 | 88 | // -------------------------------------------------------------------- |
89 | 89 | |
90 | 90 | public function __construct($config = array()) |
91 | 91 | { |
92 | - $this->CI =& get_instance(); |
|
92 | + $this->CI = & get_instance(); |
|
93 | 93 | $this->CI->load->language('profiler'); |
94 | 94 | |
95 | 95 | // If the config file has a query_toggle_count, |
96 | 96 | // use it, but remove it from the config array. |
97 | - if ( isset($config['query_toggle_count']) ) |
|
97 | + if (isset($config['query_toggle_count'])) |
|
98 | 98 | { |
99 | 99 | $this->_query_toggle_count = (int) $config['query_toggle_count']; |
100 | 100 | unset($config['query_toggle_count']); |
@@ -195,7 +195,7 @@ discard block |
||
195 | 195 | // Let's determine which databases are currently connected to |
196 | 196 | foreach (get_object_vars($this->CI) as $CI_object) |
197 | 197 | { |
198 | - if (is_object($CI_object) && is_subclass_of(get_class($CI_object), 'CI_DB') ) |
|
198 | + if (is_object($CI_object) && is_subclass_of(get_class($CI_object), 'CI_DB')) |
|
199 | 199 | { |
200 | 200 | $dbs[] = $CI_object; |
201 | 201 | } |
@@ -229,7 +229,7 @@ discard block |
||
229 | 229 | |
230 | 230 | foreach ($highlight as $bold) |
231 | 231 | { |
232 | - $val = str_replace($bold, '<b>'. $bold .'</b>', $val); |
|
232 | + $val = str_replace($bold, '<b>'.$bold.'</b>', $val); |
|
233 | 233 | } |
234 | 234 | |
235 | 235 | $output[][$time] = $val; |
@@ -268,7 +268,7 @@ discard block |
||
268 | 268 | { |
269 | 269 | if (is_array($val)) |
270 | 270 | { |
271 | - $output[$key] = "<pre>" . htmlspecialchars(stripslashes(print_r($val, true))) . "</pre>"; |
|
271 | + $output[$key] = "<pre>".htmlspecialchars(stripslashes(print_r($val, true)))."</pre>"; |
|
272 | 272 | } |
273 | 273 | else |
274 | 274 | { |
@@ -306,11 +306,11 @@ discard block |
||
306 | 306 | |
307 | 307 | if (is_array($val)) |
308 | 308 | { |
309 | - $output['$_POST['. $key .']'] = '<pre>'. htmlspecialchars(stripslashes(print_r($val, TRUE))) . '</pre>'; |
|
309 | + $output['$_POST['.$key.']'] = '<pre>'.htmlspecialchars(stripslashes(print_r($val, TRUE))).'</pre>'; |
|
310 | 310 | } |
311 | 311 | else |
312 | 312 | { |
313 | - $output['$_POST['. $key .']'] = htmlspecialchars(stripslashes($val)); |
|
313 | + $output['$_POST['.$key.']'] = htmlspecialchars(stripslashes($val)); |
|
314 | 314 | } |
315 | 315 | } |
316 | 316 | } |
@@ -366,7 +366,7 @@ discard block |
||
366 | 366 | { |
367 | 367 | if (function_exists('memory_get_usage') && ($usage = memory_get_usage()) != '') |
368 | 368 | { |
369 | - $output = number_format($usage) .' bytes'; |
|
369 | + $output = number_format($usage).' bytes'; |
|
370 | 370 | } |
371 | 371 | else |
372 | 372 | { |
@@ -389,10 +389,10 @@ discard block |
||
389 | 389 | { |
390 | 390 | $output = array(); |
391 | 391 | |
392 | - foreach (array('HTTP_ACCEPT', 'HTTP_USER_AGENT', 'HTTP_CONNECTION', 'SERVER_PORT', 'SERVER_NAME', 'REMOTE_ADDR', 'SERVER_SOFTWARE', 'HTTP_ACCEPT_LANGUAGE', 'SCRIPT_NAME', 'REQUEST_METHOD',' HTTP_HOST', 'REMOTE_HOST', 'CONTENT_TYPE', 'SERVER_PROTOCOL', 'QUERY_STRING', 'HTTP_ACCEPT_ENCODING', 'HTTP_X_FORWARDED_FOR') as $header) |
|
392 | + foreach (array('HTTP_ACCEPT', 'HTTP_USER_AGENT', 'HTTP_CONNECTION', 'SERVER_PORT', 'SERVER_NAME', 'REMOTE_ADDR', 'SERVER_SOFTWARE', 'HTTP_ACCEPT_LANGUAGE', 'SCRIPT_NAME', 'REQUEST_METHOD', ' HTTP_HOST', 'REMOTE_HOST', 'CONTENT_TYPE', 'SERVER_PROTOCOL', 'QUERY_STRING', 'HTTP_ACCEPT_ENCODING', 'HTTP_X_FORWARDED_FOR') as $header) |
|
393 | 393 | { |
394 | 394 | $val = (isset($_SERVER[$header])) ? $_SERVER[$header] : ''; |
395 | - $output[$header] = $val; |
|
395 | + $output[$header] = $val; |
|
396 | 396 | } |
397 | 397 | |
398 | 398 | return $output; |
@@ -196,7 +196,7 @@ discard block |
||
196 | 196 | Load Time |
197 | 197 | </a> |
198 | 198 | <a href="#" id="ci-profiler-menu-memory" onclick="ci_profiler_bar.show('ci-profiler-memory', 'ci-profiler-menu-memory'); return false;"> |
199 | - <span><?php echo (! function_exists('memory_get_usage')) ? '0' : round(memory_get_usage()/1024/1024, 2).' MB' ?></span> |
|
199 | + <span><?php echo ( ! function_exists('memory_get_usage')) ? '0' : round(memory_get_usage() / 1024 / 1024, 2).' MB' ?></span> |
|
200 | 200 | Memory Used |
201 | 201 | </a> |
202 | 202 | <?php endif; ?> |
@@ -384,7 +384,7 @@ discard block |
||
384 | 384 | |
385 | 385 | <?php $append = ($section == 'get' || $section == 'post') ? '_data' : '' ?> |
386 | 386 | <a href="#" onclick="ci_profiler_bar.toggle_data_table('<?php echo $section ?>'); return false;"> |
387 | - <h2><?php echo lang('profiler_' . $section . $append) ?></h2> |
|
387 | + <h2><?php echo lang('profiler_'.$section.$append) ?></h2> |
|
388 | 388 | </a> |
389 | 389 | |
390 | 390 |
@@ -79,7 +79,7 @@ discard block |
||
79 | 79 | |
80 | 80 | if (is_array($folders)) |
81 | 81 | { |
82 | - $this->module_path = $folders[0] . strtolower($module) .'/'; |
|
82 | + $this->module_path = $folders[0].strtolower($module).'/'; |
|
83 | 83 | } |
84 | 84 | } |
85 | 85 | |
@@ -101,7 +101,7 @@ discard block |
||
101 | 101 | * @param bool $quiet If true, models should accept default values. |
102 | 102 | * @return mixed |
103 | 103 | */ |
104 | - abstract function run($segments=[], $quiet=false); |
|
104 | + abstract function run($segments = [], $quiet = false); |
|
105 | 105 | |
106 | 106 | //-------------------------------------------------------------------- |
107 | 107 | |
@@ -114,7 +114,7 @@ discard block |
||
114 | 114 | * |
115 | 115 | * @return bool |
116 | 116 | */ |
117 | - public function createFile($path, $contents=null, $overwrite=false, $perms=0644) |
|
117 | + public function createFile($path, $contents = null, $overwrite = false, $perms = 0644) |
|
118 | 118 | { |
119 | 119 | $path = $this->sandbox($path); |
120 | 120 | |
@@ -123,8 +123,8 @@ discard block |
||
123 | 123 | // Does file already exist? |
124 | 124 | if ($file_exists) |
125 | 125 | { |
126 | - if (! $overwrite) { |
|
127 | - CLI::write( CLI::color("\t". strtolower(lang('exists')) .": ", 'blue') . str_replace(APPPATH, '', $path ) ); |
|
126 | + if ( ! $overwrite) { |
|
127 | + CLI::write(CLI::color("\t".strtolower(lang('exists')).": ", 'blue').str_replace(APPPATH, '', $path)); |
|
128 | 128 | return true; |
129 | 129 | } |
130 | 130 | |
@@ -136,27 +136,27 @@ discard block |
||
136 | 136 | array_pop($segments); |
137 | 137 | $folder = implode('/', $segments); |
138 | 138 | |
139 | - if (! is_dir($folder)) |
|
139 | + if ( ! is_dir($folder)) |
|
140 | 140 | { |
141 | 141 | $this->createDirectory($folder); |
142 | 142 | } |
143 | 143 | |
144 | 144 | get_instance()->load->helper('file'); |
145 | 145 | |
146 | - if (! write_file($path, $contents)) |
|
146 | + if ( ! write_file($path, $contents)) |
|
147 | 147 | { |
148 | - throw new \RuntimeException( sprintf( lang('errors.writing_file'), $path) ); |
|
148 | + throw new \RuntimeException(sprintf(lang('errors.writing_file'), $path)); |
|
149 | 149 | } |
150 | 150 | |
151 | 151 | chmod($path, $perms); |
152 | 152 | |
153 | 153 | if ($overwrite && $file_exists) |
154 | 154 | { |
155 | - CLI::write( CLI::color("\t". strtolower( lang('overwrote') ) ." ", 'light_red') . str_replace(APPPATH, '', $path ) ); |
|
155 | + CLI::write(CLI::color("\t".strtolower(lang('overwrote'))." ", 'light_red').str_replace(APPPATH, '', $path)); |
|
156 | 156 | } |
157 | 157 | else |
158 | 158 | { |
159 | - CLI::write( CLI::color("\t". strtolower( lang('created') ) ." ", 'yellow') . str_replace(APPPATH, '', $path ) ); |
|
159 | + CLI::write(CLI::color("\t".strtolower(lang('created'))." ", 'yellow').str_replace(APPPATH, '', $path)); |
|
160 | 160 | } |
161 | 161 | |
162 | 162 | return $this; |
@@ -172,7 +172,7 @@ discard block |
||
172 | 172 | * |
173 | 173 | * @return bool |
174 | 174 | */ |
175 | - public function createDirectory($path, $perms=0755) |
|
175 | + public function createDirectory($path, $perms = 0755) |
|
176 | 176 | { |
177 | 177 | $path = $this->sandbox($path); |
178 | 178 | |
@@ -181,9 +181,9 @@ discard block |
||
181 | 181 | return $this; |
182 | 182 | } |
183 | 183 | |
184 | - if (! mkdir($path, $perms, true) ) |
|
184 | + if ( ! mkdir($path, $perms, true)) |
|
185 | 185 | { |
186 | - throw new \RuntimeException( sprintf( lang('errors.creating_dir'), $path) ); |
|
186 | + throw new \RuntimeException(sprintf(lang('errors.creating_dir'), $path)); |
|
187 | 187 | } |
188 | 188 | |
189 | 189 | return $this; |
@@ -200,11 +200,11 @@ discard block |
||
200 | 200 | * |
201 | 201 | * @return bool |
202 | 202 | */ |
203 | - public function copyFile($source, $destination, $overwrite=false) |
|
203 | + public function copyFile($source, $destination, $overwrite = false) |
|
204 | 204 | { |
205 | 205 | $source = $this->sandbox($source); |
206 | 206 | |
207 | - if (! file_exists($source)) |
|
207 | + if ( ! file_exists($source)) |
|
208 | 208 | { |
209 | 209 | return null; |
210 | 210 | } |
@@ -227,9 +227,9 @@ discard block |
||
227 | 227 | * |
228 | 228 | * @return $this |
229 | 229 | */ |
230 | - public function copyTemplate($template, $destination, $data=[], $overwrite=false) |
|
230 | + public function copyTemplate($template, $destination, $data = [], $overwrite = false) |
|
231 | 231 | { |
232 | - if (! is_array($data)) |
|
232 | + if ( ! is_array($data)) |
|
233 | 233 | { |
234 | 234 | $data = array($data); |
235 | 235 | } |
@@ -259,7 +259,7 @@ discard block |
||
259 | 259 | * |
260 | 260 | * @return $this |
261 | 261 | */ |
262 | - public function injectIntoFile($path, $content, $options='append') |
|
262 | + public function injectIntoFile($path, $content, $options = 'append') |
|
263 | 263 | { |
264 | 264 | $kit = new FileKit(); |
265 | 265 | |
@@ -270,11 +270,11 @@ discard block |
||
270 | 270 | else if (is_array($options) && count($options)) |
271 | 271 | { |
272 | 272 | $keys = array_keys($options); |
273 | - $action = array_shift( $keys ); |
|
273 | + $action = array_shift($keys); |
|
274 | 274 | $param = $options[$action]; |
275 | 275 | } |
276 | 276 | |
277 | - switch ( strtolower($action) ) |
|
277 | + switch (strtolower($action)) |
|
278 | 278 | { |
279 | 279 | case 'prepend': |
280 | 280 | $success = $kit->prepend($path, $content); |
@@ -299,11 +299,11 @@ discard block |
||
299 | 299 | |
300 | 300 | if ($success) |
301 | 301 | { |
302 | - CLI::write( CLI::color("\t". strtolower( lang('modified') ) ." ", 'cyan') . str_replace(APPPATH, '', $path ) ); |
|
302 | + CLI::write(CLI::color("\t".strtolower(lang('modified'))." ", 'cyan').str_replace(APPPATH, '', $path)); |
|
303 | 303 | } |
304 | 304 | else |
305 | 305 | { |
306 | - CLI::write( CLI::color("\t". strtolower( lang('error') ) ." ", 'light_red') . str_replace(APPPATH, '', $path ) ); |
|
306 | + CLI::write(CLI::color("\t".strtolower(lang('error'))." ", 'light_red').str_replace(APPPATH, '', $path)); |
|
307 | 307 | } |
308 | 308 | |
309 | 309 | return $this; |
@@ -320,10 +320,10 @@ discard block |
||
320 | 320 | * @param $command |
321 | 321 | * @param null $options |
322 | 322 | */ |
323 | - public function generate($command, $options = '', $quiet=false) |
|
323 | + public function generate($command, $options = '', $quiet = false) |
|
324 | 324 | { |
325 | 325 | $orig_options = CLI::optionString(); |
326 | - $options = $orig_options .' '. $options; |
|
326 | + $options = $orig_options.' '.$options; |
|
327 | 327 | |
328 | 328 | if ($quiet === true) |
329 | 329 | { |
@@ -335,7 +335,7 @@ discard block |
||
335 | 335 | $options .= ' -overwrite'; |
336 | 336 | } |
337 | 337 | |
338 | - passthru( "php sprint forge {$command} {$options}" ); |
|
338 | + passthru("php sprint forge {$command} {$options}"); |
|
339 | 339 | } |
340 | 340 | |
341 | 341 | //-------------------------------------------------------------------- |
@@ -348,7 +348,7 @@ discard block |
||
348 | 348 | * |
349 | 349 | * @return \Myth\Forge\BaseGenerator |
350 | 350 | */ |
351 | - public function route($left, $right, $options=[], $method='any') |
|
351 | + public function route($left, $right, $options = [], $method = 'any') |
|
352 | 352 | { |
353 | 353 | $option_str = '['; |
354 | 354 | |
@@ -361,7 +361,7 @@ discard block |
||
361 | 361 | |
362 | 362 | $content = "\$routes->{$method}('{$left}', '{$right}', {$option_str});\n"; |
363 | 363 | |
364 | - return $this->injectIntoFile(APPPATH .'config/routes.php', $content, ['after' => "// Auto-generated routes go here\n"]); |
|
364 | + return $this->injectIntoFile(APPPATH.'config/routes.php', $content, ['after' => "// Auto-generated routes go here\n"]); |
|
365 | 365 | } |
366 | 366 | |
367 | 367 | //-------------------------------------------------------------------- |
@@ -369,21 +369,21 @@ discard block |
||
369 | 369 | /** |
370 | 370 | * Outputs the contents of the file in the template's source path. |
371 | 371 | */ |
372 | - public function readme($file='readme.txt') |
|
372 | + public function readme($file = 'readme.txt') |
|
373 | 373 | { |
374 | 374 | $name = str_replace('Generator', '', get_class($this)); |
375 | 375 | |
376 | 376 | $path = $this->locateGenerator($name); |
377 | 377 | |
378 | - if (! file_exists($path . $file)) |
|
378 | + if ( ! file_exists($path.$file)) |
|
379 | 379 | { |
380 | - CLI::error(sprintf( lang('forge.cant_find_readme'), $file) ); |
|
380 | + CLI::error(sprintf(lang('forge.cant_find_readme'), $file)); |
|
381 | 381 | } |
382 | 382 | |
383 | - $contents = file_get_contents($path . $file); |
|
383 | + $contents = file_get_contents($path.$file); |
|
384 | 384 | |
385 | 385 | CLI::new_line(2); |
386 | - CLI::write( CLI::wrap($contents), 'green' ); |
|
386 | + CLI::write(CLI::wrap($contents), 'green'); |
|
387 | 387 | CLI::new_line(); |
388 | 388 | } |
389 | 389 | |
@@ -399,7 +399,7 @@ discard block |
||
399 | 399 | * |
400 | 400 | * @return string The rendered template |
401 | 401 | */ |
402 | - public function render($template_name, $data=[], $folder=null) |
|
402 | + public function render($template_name, $data = [], $folder = null) |
|
403 | 403 | { |
404 | 404 | if (empty($this->themer)) |
405 | 405 | { |
@@ -410,27 +410,27 @@ discard block |
||
410 | 410 | |
411 | 411 | $output = null; |
412 | 412 | |
413 | - $view = $template_name .'.tpl'; |
|
413 | + $view = $template_name.'.tpl'; |
|
414 | 414 | |
415 | 415 | $groups = config_item('forge.collections'); |
416 | 416 | |
417 | - $name = str_replace('Generator', '', get_class($this) ); |
|
417 | + $name = str_replace('Generator', '', get_class($this)); |
|
418 | 418 | |
419 | 419 | foreach ($groups as $group => $path) |
420 | 420 | { |
421 | - $path = rtrim($path, '/ ') .'/'; |
|
421 | + $path = rtrim($path, '/ ').'/'; |
|
422 | 422 | $folders = scandir($path); |
423 | 423 | |
424 | - if (! $i = array_search(ucfirst($name), $folders)) |
|
424 | + if ( ! $i = array_search(ucfirst($name), $folders)) |
|
425 | 425 | { |
426 | 426 | continue; |
427 | 427 | } |
428 | 428 | |
429 | - $view = $folders[$i] . '/'. $view; |
|
429 | + $view = $folders[$i].'/'.$view; |
|
430 | 430 | |
431 | - if (realpath($path . $view .'.php')) |
|
431 | + if (realpath($path.$view.'.php')) |
|
432 | 432 | { |
433 | - $output = $this->themer->display($group .':'. $view, $data); |
|
433 | + $output = $this->themer->display($group.':'.$view, $data); |
|
434 | 434 | break; |
435 | 435 | } |
436 | 436 | } |
@@ -461,24 +461,24 @@ discard block |
||
461 | 461 | $path = $this->normalizePath($path); |
462 | 462 | |
463 | 463 | // If it's writing to BASEPATH - FIX IT |
464 | - if (strpos($path, $this->normalizePath(BASEPATH) ) === 0) |
|
464 | + if (strpos($path, $this->normalizePath(BASEPATH)) === 0) |
|
465 | 465 | { |
466 | - return APPPATH . $path; |
|
466 | + return APPPATH.$path; |
|
467 | 467 | } |
468 | 468 | |
469 | 469 | // Exact match for FCPATH? |
470 | - if (strpos($path, $this->normalizePath(FCPATH) ) === 0) |
|
470 | + if (strpos($path, $this->normalizePath(FCPATH)) === 0) |
|
471 | 471 | { |
472 | 472 | return $path; |
473 | 473 | } |
474 | 474 | |
475 | 475 | // Exact match for APPPATH? |
476 | - if (strpos($path, $this->normalizePath(APPPATH) ) === 0) |
|
476 | + if (strpos($path, $this->normalizePath(APPPATH)) === 0) |
|
477 | 477 | { |
478 | 478 | return $path; |
479 | 479 | } |
480 | 480 | |
481 | - return APPPATH . $path; |
|
481 | + return APPPATH.$path; |
|
482 | 482 | } |
483 | 483 | |
484 | 484 | //-------------------------------------------------------------------- |
@@ -493,12 +493,12 @@ discard block |
||
493 | 493 | { |
494 | 494 | $themer_name = config_item('forge.themer'); |
495 | 495 | |
496 | - if (! $themer_name) |
|
496 | + if ( ! $themer_name) |
|
497 | 497 | { |
498 | - throw new \RuntimeException( lang('forge.no_themer') ); |
|
498 | + throw new \RuntimeException(lang('forge.no_themer')); |
|
499 | 499 | } |
500 | 500 | |
501 | - $this->themer = new $themer_name( get_instance() ); |
|
501 | + $this->themer = new $themer_name(get_instance()); |
|
502 | 502 | |
503 | 503 | // Register our paths with the themer |
504 | 504 | $paths = config_item('forge.collections'); |
@@ -514,9 +514,9 @@ discard block |
||
514 | 514 | { |
515 | 515 | $kit_name = config_item('theme.uikit'); |
516 | 516 | |
517 | - if (! $kit_name) |
|
517 | + if ( ! $kit_name) |
|
518 | 518 | { |
519 | - throw new \RuntimeException( lang('forge.no_uikit') ); |
|
519 | + throw new \RuntimeException(lang('forge.no_uikit')); |
|
520 | 520 | } |
521 | 521 | |
522 | 522 | $uikit = new $kit_name(); |
@@ -527,16 +527,16 @@ discard block |
||
527 | 527 | //-------------------------------------------------------------------- |
528 | 528 | |
529 | 529 | |
530 | - protected function determineOutputPath($folder='') |
|
530 | + protected function determineOutputPath($folder = '') |
|
531 | 531 | { |
532 | - $path = APPPATH . $folder; |
|
532 | + $path = APPPATH.$folder; |
|
533 | 533 | |
534 | - if (! empty($this->module_path)) |
|
534 | + if ( ! empty($this->module_path)) |
|
535 | 535 | { |
536 | - $path = $this->module_path . $folder; |
|
536 | + $path = $this->module_path.$folder; |
|
537 | 537 | } |
538 | 538 | |
539 | - return rtrim($path, '/ ') .'/'; |
|
539 | + return rtrim($path, '/ ').'/'; |
|
540 | 540 | } |
541 | 541 | |
542 | 542 | //-------------------------------------------------------------------- |
@@ -552,22 +552,22 @@ discard block |
||
552 | 552 | { |
553 | 553 | $collections = config_item('forge.collections'); |
554 | 554 | |
555 | - if (! is_array($collections) || ! count($collections) ) |
|
555 | + if ( ! is_array($collections) || ! count($collections)) |
|
556 | 556 | { |
557 | - return CLI::error( lang('forge.no_collections') ); |
|
557 | + return CLI::error(lang('forge.no_collections')); |
|
558 | 558 | } |
559 | 559 | |
560 | 560 | foreach ($collections as $alias => $path) |
561 | 561 | { |
562 | - $path = rtrim($path, '/ ') .'/'; |
|
562 | + $path = rtrim($path, '/ ').'/'; |
|
563 | 563 | $folders = scandir($path); |
564 | 564 | |
565 | - if (! $i = array_search(ucfirst($name), $folders)) |
|
565 | + if ( ! $i = array_search(ucfirst($name), $folders)) |
|
566 | 566 | { |
567 | 567 | continue; |
568 | 568 | } |
569 | 569 | |
570 | - $this->gen_path = $path . $folders[$i] .'/'; |
|
570 | + $this->gen_path = $path.$folders[$i].'/'; |
|
571 | 571 | |
572 | 572 | return $this->gen_path; |
573 | 573 | } |
@@ -584,9 +584,9 @@ discard block |
||
584 | 584 | * |
585 | 585 | * @return string |
586 | 586 | */ |
587 | - protected function stringify($array, $depth=0) |
|
587 | + protected function stringify($array, $depth = 0) |
|
588 | 588 | { |
589 | - if (! is_array($array)) |
|
589 | + if ( ! is_array($array)) |
|
590 | 590 | { |
591 | 591 | return ''; |
592 | 592 | } |
@@ -606,9 +606,9 @@ discard block |
||
606 | 606 | |
607 | 607 | foreach ($array as $key => $value) |
608 | 608 | { |
609 | - $str .= str_repeat("\t", $depth +1); |
|
609 | + $str .= str_repeat("\t", $depth + 1); |
|
610 | 610 | |
611 | - if (! is_numeric($key)) |
|
611 | + if ( ! is_numeric($key)) |
|
612 | 612 | { |
613 | 613 | $str .= "'{$key}' => "; |
614 | 614 | } |
@@ -632,7 +632,7 @@ discard block |
||
632 | 632 | } |
633 | 633 | } |
634 | 634 | |
635 | - $str .= str_repeat("\t", $depth) ."],"; |
|
635 | + $str .= str_repeat("\t", $depth)."],"; |
|
636 | 636 | |
637 | 637 | return $str; |
638 | 638 | } |
@@ -667,13 +667,13 @@ discard block |
||
667 | 667 | // Initialize testing variable |
668 | 668 | $test = ''; |
669 | 669 | |
670 | - foreach($segments as $segment) |
|
670 | + foreach ($segments as $segment) |
|
671 | 671 | { |
672 | - if($segment != '.') |
|
672 | + if ($segment != '.') |
|
673 | 673 | { |
674 | 674 | $test = array_pop($parts); |
675 | 675 | |
676 | - if(is_null($test)) |
|
676 | + if (is_null($test)) |
|
677 | 677 | { |
678 | 678 | $parts[] = $segment; |
679 | 679 | } |
@@ -47,7 +47,7 @@ discard block |
||
47 | 47 | } |
48 | 48 | |
49 | 49 | // Ensure that $content has a newline at the end |
50 | - $content = rtrim($content) ."\n"; |
|
50 | + $content = rtrim($content)."\n"; |
|
51 | 51 | |
52 | 52 | $fh = fopen($file, 'a'); |
53 | 53 | $result = fwrite($fh, $content); |
@@ -75,18 +75,18 @@ discard block |
||
75 | 75 | } |
76 | 76 | |
77 | 77 | // Ensure that $content has a newline at the end |
78 | - $content = rtrim($content) ."\n"; |
|
78 | + $content = rtrim($content)."\n"; |
|
79 | 79 | |
80 | 80 | $file_contents = file_get_contents($file); |
81 | 81 | |
82 | 82 | if ($file_contents === false) |
83 | 83 | { |
84 | - throw new \RuntimeException( sprintf(lang('errors.reading_file'), $file)); |
|
84 | + throw new \RuntimeException(sprintf(lang('errors.reading_file'), $file)); |
|
85 | 85 | } |
86 | 86 | |
87 | - $result = file_put_contents($file, $content . $file_contents); |
|
87 | + $result = file_put_contents($file, $content.$file_contents); |
|
88 | 88 | |
89 | - return (bool)$result; |
|
89 | + return (bool) $result; |
|
90 | 90 | } |
91 | 91 | |
92 | 92 | //-------------------------------------------------------------------- |
@@ -108,13 +108,13 @@ discard block |
||
108 | 108 | } |
109 | 109 | |
110 | 110 | // Ensure that $content has a newline at the end |
111 | - $content = rtrim($content) ."\n"; |
|
111 | + $content = rtrim($content)."\n"; |
|
112 | 112 | |
113 | 113 | $lines = file($file); |
114 | 114 | |
115 | 115 | if ($lines === false) |
116 | 116 | { |
117 | - throw new \RuntimeException( sprintf( lang('errors.file_not_found'), $file )); |
|
117 | + throw new \RuntimeException(sprintf(lang('errors.file_not_found'), $file)); |
|
118 | 118 | } |
119 | 119 | |
120 | 120 | // Where to insert the row. |
@@ -122,7 +122,7 @@ discard block |
||
122 | 122 | |
123 | 123 | foreach ($lines as $index => $line) |
124 | 124 | { |
125 | - if (strtolower($line) == strtolower($before) ) |
|
125 | + if (strtolower($line) == strtolower($before)) |
|
126 | 126 | { |
127 | 127 | $location = $index; |
128 | 128 | break; |
@@ -133,7 +133,7 @@ discard block |
||
133 | 133 | |
134 | 134 | $result = file_put_contents($file, $lines); |
135 | 135 | |
136 | - return (bool)$result; |
|
136 | + return (bool) $result; |
|
137 | 137 | } |
138 | 138 | |
139 | 139 | //-------------------------------------------------------------------- |
@@ -146,13 +146,13 @@ discard block |
||
146 | 146 | } |
147 | 147 | |
148 | 148 | // Ensure that $content has a newline at the end |
149 | - $content = rtrim($content) ."\n"; |
|
149 | + $content = rtrim($content)."\n"; |
|
150 | 150 | |
151 | 151 | $lines = file($file); |
152 | 152 | |
153 | 153 | if ($lines === false) |
154 | 154 | { |
155 | - throw new \RuntimeException( sprintf( lang('errors.file_not_found'), $file ) ); |
|
155 | + throw new \RuntimeException(sprintf(lang('errors.file_not_found'), $file)); |
|
156 | 156 | } |
157 | 157 | |
158 | 158 | // Where to insert the row. |
@@ -160,18 +160,18 @@ discard block |
||
160 | 160 | |
161 | 161 | foreach ($lines as $index => $line) |
162 | 162 | { |
163 | - if (strtolower($line) == strtolower($after) ) |
|
163 | + if (strtolower($line) == strtolower($after)) |
|
164 | 164 | { |
165 | 165 | $location = $index; |
166 | 166 | break; |
167 | 167 | } |
168 | 168 | } |
169 | 169 | |
170 | - array_splice($lines, $location +1, 0, $content); |
|
170 | + array_splice($lines, $location + 1, 0, $content); |
|
171 | 171 | |
172 | 172 | $result = file_put_contents($file, $lines); |
173 | 173 | |
174 | - return (bool)$result; |
|
174 | + return (bool) $result; |
|
175 | 175 | } |
176 | 176 | |
177 | 177 | //-------------------------------------------------------------------- |
@@ -190,14 +190,14 @@ discard block |
||
190 | 190 | |
191 | 191 | if ($file_contents === false) |
192 | 192 | { |
193 | - throw new \RuntimeException( sprintf( lang('errors.reading_file'), $file ) ); |
|
193 | + throw new \RuntimeException(sprintf(lang('errors.reading_file'), $file)); |
|
194 | 194 | } |
195 | 195 | |
196 | 196 | $file_contents = str_replace($search, $replace, $file_contents); |
197 | 197 | |
198 | 198 | $result = file_put_contents($file, $file_contents); |
199 | 199 | |
200 | - return (bool)$result; |
|
200 | + return (bool) $result; |
|
201 | 201 | } |
202 | 202 | |
203 | 203 | //-------------------------------------------------------------------- |
@@ -216,7 +216,7 @@ discard block |
||
216 | 216 | |
217 | 217 | if ($file_contents === false) |
218 | 218 | { |
219 | - throw new \RuntimeException( sprintf( lang('errors.reading_file'), $file ) ); |
|
219 | + throw new \RuntimeException(sprintf(lang('errors.reading_file'), $file)); |
|
220 | 220 | } |
221 | 221 | |
222 | 222 | $file_contents = preg_replace($pattern, $replace, $file_contents); |
@@ -224,12 +224,12 @@ discard block |
||
224 | 224 | $result = false; |
225 | 225 | |
226 | 226 | // Don't let us erase a file! |
227 | - if (! empty($file_contents)) |
|
227 | + if ( ! empty($file_contents)) |
|
228 | 228 | { |
229 | - $result = file_put_contents( $file, $file_contents ); |
|
229 | + $result = file_put_contents($file, $file_contents); |
|
230 | 230 | } |
231 | 231 | |
232 | - return (bool)$result; |
|
232 | + return (bool) $result; |
|
233 | 233 | } |
234 | 234 | |
235 | 235 | //-------------------------------------------------------------------- |
@@ -64,7 +64,7 @@ discard block |
||
64 | 64 | * will use the system default. |
65 | 65 | * @var null |
66 | 66 | */ |
67 | - protected $service_name = null; |
|
67 | + protected $service_name = null; |
|
68 | 68 | |
69 | 69 | protected $service = null; |
70 | 70 | |
@@ -83,9 +83,9 @@ discard block |
||
83 | 83 | * |
84 | 84 | * @param null $options |
85 | 85 | */ |
86 | - public function __construct($options=null) |
|
86 | + public function __construct($options = null) |
|
87 | 87 | { |
88 | - if (! empty($options)) |
|
88 | + if ( ! empty($options)) |
|
89 | 89 | { |
90 | 90 | $this->setOptions($options); |
91 | 91 | } |
@@ -107,7 +107,7 @@ discard block |
||
107 | 107 | { |
108 | 108 | if ($key == 'service') |
109 | 109 | { |
110 | - $this->service =& $value; |
|
110 | + $this->service = & $value; |
|
111 | 111 | continue; |
112 | 112 | } |
113 | 113 | |
@@ -135,7 +135,7 @@ discard block |
||
135 | 135 | * |
136 | 136 | * @return bool |
137 | 137 | */ |
138 | - public function send($to, $subject, $data=[], $view=null) |
|
138 | + public function send($to, $subject, $data = [], $view = null) |
|
139 | 139 | { |
140 | 140 | // Are we pretending to send? |
141 | 141 | if (config_item('mail.pretend') === true) |
@@ -156,8 +156,8 @@ discard block |
||
156 | 156 | $this->service->from($this->from); |
157 | 157 | } |
158 | 158 | |
159 | - if (! empty($this->cc)) $this->service->cc($this->cc); |
|
160 | - if (! empty($this->bcc)) $this->service->bcc($this->bcc); |
|
159 | + if ( ! empty($this->cc)) $this->service->cc($this->cc); |
|
160 | + if ( ! empty($this->bcc)) $this->service->bcc($this->bcc); |
|
161 | 161 | |
162 | 162 | if (is_array($this->reply_to)) { |
163 | 163 | $this->service->reply_to($this->reply_to[0], $this->reply_to[1]); |
@@ -172,20 +172,20 @@ discard block |
||
172 | 172 | // the debug_backtrace, though, to make it all function in the background. |
173 | 173 | list(, $method) = debug_backtrace(false); |
174 | 174 | |
175 | - $view = 'emails/'. strtolower( (new \ReflectionClass($this))->getShortName() ) .'/'. $method['function']; |
|
175 | + $view = 'emails/'.strtolower((new \ReflectionClass($this))->getShortName()).'/'.$method['function']; |
|
176 | 176 | |
177 | 177 | // Get our message's text and html versions based on which files exist... |
178 | - $basepath = APPPATH .'views/'. $view; |
|
178 | + $basepath = APPPATH.'views/'.$view; |
|
179 | 179 | |
180 | 180 | // Is a text version available? |
181 | - if (file_exists($basepath .'.text.php')) |
|
181 | + if (file_exists($basepath.'.text.php')) |
|
182 | 182 | { |
183 | - $text = $this->load->view($view .'.text.php', $data, true); |
|
183 | + $text = $this->load->view($view.'.text.php', $data, true); |
|
184 | 184 | $this->service->text_message($text); |
185 | 185 | } |
186 | 186 | |
187 | 187 | // If an html version is around, we need to theme it out |
188 | - if (file_exists($basepath .'.html.php')) |
|
188 | + if (file_exists($basepath.'.html.php')) |
|
189 | 189 | { |
190 | 190 | $this->startThemer(); |
191 | 191 | |
@@ -198,14 +198,14 @@ discard block |
||
198 | 198 | $this->themer->set($data); |
199 | 199 | |
200 | 200 | // Render the view into a var we can pass to the layout. |
201 | - $content = $this->themer->display($view .'.html.php'); |
|
201 | + $content = $this->themer->display($view.'.html.php'); |
|
202 | 202 | |
203 | 203 | $this->themer->set('content', $content); |
204 | 204 | |
205 | - $this->service->html_message( $this->themer->display($this->theme .':'. $layout) ); |
|
205 | + $this->service->html_message($this->themer->display($this->theme.':'.$layout)); |
|
206 | 206 | } |
207 | 207 | |
208 | - if (! $this->service->send() ) |
|
208 | + if ( ! $this->service->send()) |
|
209 | 209 | { |
210 | 210 | // todo do something here |
211 | 211 | return false; |
@@ -224,7 +224,7 @@ discard block |
||
224 | 224 | * @param string|array $field |
225 | 225 | * @param string $value |
226 | 226 | */ |
227 | - public function header($field, $value=null) |
|
227 | + public function header($field, $value = null) |
|
228 | 228 | { |
229 | 229 | $this->startMailService(); |
230 | 230 | |
@@ -241,7 +241,7 @@ discard block |
||
241 | 241 | * @param string $newname If you'd like to rename the file for delivery |
242 | 242 | * @param string $mime Custom defined mime type. |
243 | 243 | */ |
244 | - public function attach($filename, $disposition=null, $newname=null, $mime=null) |
|
244 | + public function attach($filename, $disposition = null, $newname = null, $mime = null) |
|
245 | 245 | { |
246 | 246 | $this->startMailService(); |
247 | 247 | |
@@ -262,16 +262,16 @@ discard block |
||
262 | 262 | protected function startMailService() |
263 | 263 | { |
264 | 264 | // Only once! |
265 | - if (! empty($this->service) && is_object($this->service)) |
|
265 | + if ( ! empty($this->service) && is_object($this->service)) |
|
266 | 266 | { |
267 | 267 | return; |
268 | 268 | } |
269 | 269 | |
270 | 270 | $service_name = ! empty($this->service_name) ? $this->service_name : config_item('mail.default_service'); |
271 | 271 | |
272 | - if (! class_exists($service_name)) |
|
272 | + if ( ! class_exists($service_name)) |
|
273 | 273 | { |
274 | - throw new \RuntimeException( sprintf( lang('mail.invalid_service'), $service_name) ); |
|
274 | + throw new \RuntimeException(sprintf(lang('mail.invalid_service'), $service_name)); |
|
275 | 275 | } |
276 | 276 | |
277 | 277 | $this->service = new $service_name(); |
@@ -290,12 +290,12 @@ discard block |
||
290 | 290 | $themer = config_item('active_themer'); |
291 | 291 | |
292 | 292 | if (empty($themer)) { |
293 | - throw new \RuntimeException( lang('no_themer') ); |
|
293 | + throw new \RuntimeException(lang('no_themer')); |
|
294 | 294 | } |
295 | 295 | |
296 | 296 | if (empty($this->themer)) |
297 | 297 | { |
298 | - $this->themer = new $themer( get_instance() ); |
|
298 | + $this->themer = new $themer(get_instance()); |
|
299 | 299 | } |
300 | 300 | |
301 | 301 | // Register our paths with the themer |
@@ -306,7 +306,7 @@ discard block |
||
306 | 306 | } |
307 | 307 | |
308 | 308 | // Set our default theme. |
309 | - $this->themer->setDefaultTheme( 'email' ); |
|
309 | + $this->themer->setDefaultTheme('email'); |
|
310 | 310 | } |
311 | 311 | |
312 | 312 | //-------------------------------------------------------------------- |
@@ -48,7 +48,7 @@ discard block |
||
48 | 48 | |
49 | 49 | public function __construct() |
50 | 50 | { |
51 | - $this->ci =& get_instance(); |
|
51 | + $this->ci = & get_instance(); |
|
52 | 52 | |
53 | 53 | $this->ci->load->library('email'); |
54 | 54 | } |
@@ -63,7 +63,7 @@ discard block |
||
63 | 63 | * |
64 | 64 | * @return mixed |
65 | 65 | */ |
66 | - public function send($clear_after=true) |
|
66 | + public function send($clear_after = true) |
|
67 | 67 | { |
68 | 68 | $this->ci->email->mailtype = $this->format; |
69 | 69 | |
@@ -82,7 +82,7 @@ discard block |
||
82 | 82 | * @param string $newname If you'd like to rename the file for delivery |
83 | 83 | * @param string $mime Custom defined mime type. |
84 | 84 | */ |
85 | - public function attach($filename, $disposition=null, $newname=null, $mime=null) |
|
85 | + public function attach($filename, $disposition = null, $newname = null, $mime = null) |
|
86 | 86 | { |
87 | 87 | $this->ci->email->attach($filename, $disposition, $newname, $mime); |
88 | 88 | } |
@@ -131,7 +131,7 @@ discard block |
||
131 | 131 | * @param null $name |
132 | 132 | * @return mixed |
133 | 133 | */ |
134 | - public function from($email, $name=null) |
|
134 | + public function from($email, $name = null) |
|
135 | 135 | { |
136 | 136 | $this->ci->email->from($email, $name); |
137 | 137 | |
@@ -176,7 +176,7 @@ discard block |
||
176 | 176 | * @param $email |
177 | 177 | * @return mixed |
178 | 178 | */ |
179 | - public function reply_to($email, $name=null) |
|
179 | + public function reply_to($email, $name = null) |
|
180 | 180 | { |
181 | 181 | $this->ci->email->reply_to($email, $name); |
182 | 182 | } |
@@ -254,7 +254,7 @@ discard block |
||
254 | 254 | * @param bool $clear_attachments |
255 | 255 | * @return mixed |
256 | 256 | */ |
257 | - public function reset($clear_attachments=true) |
|
257 | + public function reset($clear_attachments = true) |
|
258 | 258 | { |
259 | 259 | $this->ci->email->clear($clear_attachments); |
260 | 260 |
@@ -53,7 +53,7 @@ discard block |
||
53 | 53 | |
54 | 54 | public function __construct() |
55 | 55 | { |
56 | - $this->ci =& get_instance(); |
|
56 | + $this->ci = & get_instance(); |
|
57 | 57 | |
58 | 58 | $this->ci->load->library('email'); |
59 | 59 | } |
@@ -71,7 +71,7 @@ discard block |
||
71 | 71 | * |
72 | 72 | * @return mixed |
73 | 73 | */ |
74 | - public function send($clear_after=true) |
|
74 | + public function send($clear_after = true) |
|
75 | 75 | { |
76 | 76 | |
77 | 77 | // Ensure we have enough data |
@@ -79,21 +79,21 @@ discard block |
||
79 | 79 | (empty($this->html_message) && empty($this->text_message)) |
80 | 80 | ) |
81 | 81 | { |
82 | - throw new \RuntimeException( lang('mail.invalid_log_data') ); |
|
82 | + throw new \RuntimeException(lang('mail.invalid_log_data')); |
|
83 | 83 | } |
84 | 84 | |
85 | 85 | $symbols = ['#', '%', '&', '{', '}', '\\', '/', '<', '>', '*', '?', ' ', '$', '!', '\'', '"', ':', '@', '+', '`', '=']; |
86 | 86 | |
87 | - $email = str_replace($symbols, '.', strtolower($this->to) ); |
|
87 | + $email = str_replace($symbols, '.', strtolower($this->to)); |
|
88 | 88 | |
89 | - $filename = date('YmdHis_'). $email; |
|
89 | + $filename = date('YmdHis_').$email; |
|
90 | 90 | |
91 | 91 | // Ensure the emails folder exists in the log folder. |
92 | 92 | $path = config_item('log_path'); |
93 | - $path = ! empty( $path ) ? $path : APPPATH .'logs/'; |
|
94 | - $path = rtrim($path, '/ ') .'/email/'; |
|
93 | + $path = ! empty($path) ? $path : APPPATH.'logs/'; |
|
94 | + $path = rtrim($path, '/ ').'/email/'; |
|
95 | 95 | |
96 | - if (! is_dir($path)) |
|
96 | + if ( ! is_dir($path)) |
|
97 | 97 | { |
98 | 98 | mkdir($path, 0777, true); |
99 | 99 | } |
@@ -101,15 +101,15 @@ discard block |
||
101 | 101 | get_instance()->load->helper('file'); |
102 | 102 | |
103 | 103 | // Write our HTML file out |
104 | - if (! empty($this->html_message) && ! write_file( $path . $filename . '.html', $this->html_message ) ) |
|
104 | + if ( ! empty($this->html_message) && ! write_file($path.$filename.'.html', $this->html_message)) |
|
105 | 105 | { |
106 | - throw new \RuntimeException( sprintf( lang('mail.error_html_log'), $path, $filename) ); |
|
106 | + throw new \RuntimeException(sprintf(lang('mail.error_html_log'), $path, $filename)); |
|
107 | 107 | } |
108 | 108 | |
109 | 109 | // Write our TEXT file out |
110 | - if (! empty($this->text_message) && ! write_file( $path . $filename . '.txt', $this->text_message ) ) |
|
110 | + if ( ! empty($this->text_message) && ! write_file($path.$filename.'.txt', $this->text_message)) |
|
111 | 111 | { |
112 | - throw new \RuntimeException( sprintf( lang('mail.error_text_log'), $path, $filename) ); |
|
112 | + throw new \RuntimeException(sprintf(lang('mail.error_text_log'), $path, $filename)); |
|
113 | 113 | } |
114 | 114 | |
115 | 115 | return true; |
@@ -125,7 +125,7 @@ discard block |
||
125 | 125 | * @param string $newname If you'd like to rename the file for delivery |
126 | 126 | * @param string $mime Custom defined mime type. |
127 | 127 | */ |
128 | - public function attach($filename, $disposition=null, $newname=null, $mime=null) |
|
128 | + public function attach($filename, $disposition = null, $newname = null, $mime = null) |
|
129 | 129 | { |
130 | 130 | return; |
131 | 131 | } |
@@ -174,9 +174,9 @@ discard block |
||
174 | 174 | * @param null $name |
175 | 175 | * @return mixed |
176 | 176 | */ |
177 | - public function from($email, $name=null) |
|
177 | + public function from($email, $name = null) |
|
178 | 178 | { |
179 | - if (! empty($name)) |
|
179 | + if ( ! empty($name)) |
|
180 | 180 | { |
181 | 181 | $this->from = [$email, $name]; |
182 | 182 | } |
@@ -226,9 +226,9 @@ discard block |
||
226 | 226 | * @param $email |
227 | 227 | * @return mixed |
228 | 228 | */ |
229 | - public function reply_to($email, $name=null) |
|
229 | + public function reply_to($email, $name = null) |
|
230 | 230 | { |
231 | - if (! empty($name)) |
|
231 | + if ( ! empty($name)) |
|
232 | 232 | { |
233 | 233 | $this->reply_to = [$email, $name]; |
234 | 234 | } |
@@ -309,7 +309,7 @@ discard block |
||
309 | 309 | * @param bool $clear_attachments |
310 | 310 | * @return mixed |
311 | 311 | */ |
312 | - public function reset($clear_attachments=true) |
|
312 | + public function reset($clear_attachments = true) |
|
313 | 313 | { |
314 | 314 | $this->to = null; |
315 | 315 | $this->from = null; |
@@ -47,7 +47,7 @@ discard block |
||
47 | 47 | * @param array $options |
48 | 48 | * @return mixed |
49 | 49 | */ |
50 | - public static function deliver($mailer_name, $params=[], $options=[]) |
|
50 | + public static function deliver($mailer_name, $params = [], $options = []) |
|
51 | 51 | { |
52 | 52 | // Protect users from themselves here. |
53 | 53 | str_replace('::', ':', $mailer_name); |
@@ -55,28 +55,28 @@ discard block |
||
55 | 55 | // Try to load our mailer class. |
56 | 56 | list($class, $method) = explode(':', $mailer_name); |
57 | 57 | |
58 | - if (! is_file(APPPATH .'mailers/'. $class .'.php')) |
|
58 | + if ( ! is_file(APPPATH.'mailers/'.$class.'.php')) |
|
59 | 59 | { |
60 | - throw new \RuntimeException( sprintf( lang('mail.cant_find_mailer'), $class) ); |
|
60 | + throw new \RuntimeException(sprintf(lang('mail.cant_find_mailer'), $class)); |
|
61 | 61 | } |
62 | 62 | |
63 | - require_once APPPATH .'mailers/'. $class .'.php'; |
|
63 | + require_once APPPATH.'mailers/'.$class.'.php'; |
|
64 | 64 | |
65 | - if (! class_exists($class, false)) |
|
65 | + if ( ! class_exists($class, false)) |
|
66 | 66 | { |
67 | - throw new \RuntimeException( sprintf( lang('errors.cant_instantiate'), $class) ); |
|
67 | + throw new \RuntimeException(sprintf(lang('errors.cant_instantiate'), $class)); |
|
68 | 68 | } |
69 | 69 | |
70 | - $mailer = new $class( $options ); |
|
70 | + $mailer = new $class($options); |
|
71 | 71 | |
72 | - if (! method_exists($mailer, $method)) |
|
72 | + if ( ! method_exists($mailer, $method)) |
|
73 | 73 | { |
74 | - throw new \BadMethodCallException( sprintf( lang('mail.invalid_mailer_method'), $class, $method) ); |
|
74 | + throw new \BadMethodCallException(sprintf(lang('mail.invalid_mailer_method'), $class, $method)); |
|
75 | 75 | } |
76 | 76 | |
77 | 77 | // try to deliver the mail, but don't send back the contents |
78 | 78 | // since we don't want to force the mailers to return anything. |
79 | - if (call_user_func_array([$mailer, $method], $params) ) |
|
79 | + if (call_user_func_array([$mailer, $method], $params)) |
|
80 | 80 | { |
81 | 81 | return true; |
82 | 82 | } |
@@ -96,7 +96,7 @@ discard block |
||
96 | 96 | * |
97 | 97 | * @return mixed |
98 | 98 | */ |
99 | - public static function queue($mailer_name, $params=[], $options=[], &$queue=null) |
|
99 | + public static function queue($mailer_name, $params = [], $options = [], &$queue = null) |
|
100 | 100 | { |
101 | 101 | $data = [ |
102 | 102 | 'mailer' => $mailer_name, |
@@ -121,7 +121,7 @@ discard block |
||
121 | 121 | * @param int $chunk_size // How many emails to send per batch. |
122 | 122 | * @return string // The output of the cronjob... |
123 | 123 | */ |
124 | - public static function process($chunk_size=50, &$db=null) |
|
124 | + public static function process($chunk_size = 50, &$db = null) |
|
125 | 125 | { |
126 | 126 | if (empty($db)) |
127 | 127 | { |
@@ -131,19 +131,19 @@ discard block |
||
131 | 131 | // Grab our batch of emails to process |
132 | 132 | $queue = $db->find_many_by('sent', 0); |
133 | 133 | |
134 | - if (! $queue) |
|
134 | + if ( ! $queue) |
|
135 | 135 | { |
136 | 136 | // We didn't have an error, we simply |
137 | 137 | // didn't have anything to do. |
138 | 138 | return true; |
139 | 139 | } |
140 | 140 | |
141 | - $output = 'Started processing email Queue at '. date('Y-m-d H:i:s') .".\n\n"; |
|
141 | + $output = 'Started processing email Queue at '.date('Y-m-d H:i:s').".\n\n"; |
|
142 | 142 | |
143 | 143 | foreach ($queue as $item) |
144 | 144 | { |
145 | 145 | try { |
146 | - if (! Mail::deliver($item->mailer, unserialize($item->params), unserialize($item->options))) { |
|
146 | + if ( ! Mail::deliver($item->mailer, unserialize($item->params), unserialize($item->options))) { |
|
147 | 147 | $output .= '[FAILED] '; |
148 | 148 | } else { |
149 | 149 | $data = [ |
@@ -158,11 +158,11 @@ discard block |
||
158 | 158 | } |
159 | 159 | catch (\Exception $e) |
160 | 160 | { |
161 | - $output .= "[EXCEPTION] ". $e->getMessage() ."\n"; |
|
161 | + $output .= "[EXCEPTION] ".$e->getMessage()."\n"; |
|
162 | 162 | } |
163 | 163 | } |
164 | 164 | |
165 | - $output .= "Done processing email Queue at ". date('H:i:s') .".\n"; |
|
165 | + $output .= "Done processing email Queue at ".date('H:i:s').".\n"; |
|
166 | 166 | |
167 | 167 | return $output; |
168 | 168 | } |