@@ -58,7 +58,7 @@ discard block |
||
| 58 | 58 | * @param array $options |
| 59 | 59 | * @return mixed |
| 60 | 60 | */ |
| 61 | - public function row($options=[], \Closure $c) |
|
| 61 | + public function row($options = [], \Closure $c) |
|
| 62 | 62 | { |
| 63 | 63 | list($classes, $id, $attributes) = $this->parseStandardOptions($options, 'row', true); |
| 64 | 64 | |
@@ -90,7 +90,7 @@ discard block |
||
| 90 | 90 | * @param array $attributes |
| 91 | 91 | * @return mixed |
| 92 | 92 | */ |
| 93 | - public function column($options=[], \Closure $c) |
|
| 93 | + public function column($options = [], \Closure $c) |
|
| 94 | 94 | { |
| 95 | 95 | // Build our classes |
| 96 | 96 | $classes = ''; |
@@ -100,33 +100,33 @@ discard block |
||
| 100 | 100 | switch ($size) |
| 101 | 101 | { |
| 102 | 102 | case 's': |
| 103 | - $classes .= ' small-'. $value; |
|
| 103 | + $classes .= ' small-'.$value; |
|
| 104 | 104 | break; |
| 105 | 105 | case 'm': |
| 106 | - $classes .= ' medium-'. $value; |
|
| 106 | + $classes .= ' medium-'.$value; |
|
| 107 | 107 | break; |
| 108 | 108 | case 'l': |
| 109 | - $classes .= ' large-'. $value; |
|
| 109 | + $classes .= ' large-'.$value; |
|
| 110 | 110 | break; |
| 111 | 111 | case 'xl': |
| 112 | - $classes .= ' large-'. $value; |
|
| 112 | + $classes .= ' large-'.$value; |
|
| 113 | 113 | break; |
| 114 | 114 | case 's-offset': |
| 115 | - $classes .= ' small-offset-'. $value; |
|
| 115 | + $classes .= ' small-offset-'.$value; |
|
| 116 | 116 | break; |
| 117 | 117 | case 'm-offset': |
| 118 | - $classes .= ' medium-offset-'. $value; |
|
| 118 | + $classes .= ' medium-offset-'.$value; |
|
| 119 | 119 | break; |
| 120 | 120 | case 'l-offset': |
| 121 | - $classes .= ' large-offset-'. $value; |
|
| 121 | + $classes .= ' large-offset-'.$value; |
|
| 122 | 122 | break; |
| 123 | 123 | case 'xl-offset': |
| 124 | - $classes .= ' large-offset-'. $value; |
|
| 124 | + $classes .= ' large-offset-'.$value; |
|
| 125 | 125 | break; |
| 126 | 126 | } |
| 127 | 127 | } |
| 128 | 128 | |
| 129 | - $classes = $this->buildClassString($classes .' columns', $options, true); |
|
| 129 | + $classes = $this->buildClassString($classes.' columns', $options, true); |
|
| 130 | 130 | |
| 131 | 131 | $id = $this->buildIdFromOptions($options); |
| 132 | 132 | |
@@ -155,7 +155,7 @@ discard block |
||
| 155 | 155 | * @param callable $c |
| 156 | 156 | * @return string |
| 157 | 157 | */ |
| 158 | - public function navbar($options=[], \Closure $c) |
|
| 158 | + public function navbar($options = [], \Closure $c) |
|
| 159 | 159 | { |
| 160 | 160 | $output = ''; |
| 161 | 161 | |
@@ -205,7 +205,7 @@ discard block |
||
| 205 | 205 | * @param string $url |
| 206 | 206 | * @return string |
| 207 | 207 | */ |
| 208 | - public function navbarTitle($title, $url='#') |
|
| 208 | + public function navbarTitle($title, $url = '#') |
|
| 209 | 209 | { |
| 210 | 210 | return "<ul class='title-area'> |
| 211 | 211 | <li class='name'> |
@@ -227,11 +227,11 @@ discard block |
||
| 227 | 227 | * @param callable $c |
| 228 | 228 | * @return string |
| 229 | 229 | */ |
| 230 | - public function navbarRight($options=[], \Closure $c) |
|
| 230 | + public function navbarRight($options = [], \Closure $c) |
|
| 231 | 231 | { |
| 232 | 232 | $output = ''; |
| 233 | 233 | |
| 234 | - if (! isset($this->states['nav-section-open'])) |
|
| 234 | + if ( ! isset($this->states['nav-section-open'])) |
|
| 235 | 235 | { |
| 236 | 236 | $output .= "<section class='top-bar-section'>\n"; |
| 237 | 237 | $this->states['nav-section-open'] = true; |
@@ -266,11 +266,11 @@ discard block |
||
| 266 | 266 | * @param callable $c |
| 267 | 267 | * @return string |
| 268 | 268 | */ |
| 269 | - public function navbarLeft($options=[], \Closure $c) |
|
| 269 | + public function navbarLeft($options = [], \Closure $c) |
|
| 270 | 270 | { |
| 271 | 271 | $output = ''; |
| 272 | 272 | |
| 273 | - if (! isset($this->states['nav-section-open'])) |
|
| 273 | + if ( ! isset($this->states['nav-section-open'])) |
|
| 274 | 274 | { |
| 275 | 275 | $output .= "<section class='top-bar-section'>\n"; |
| 276 | 276 | $this->states['nav-section-open'] = true; |
@@ -311,7 +311,7 @@ discard block |
||
| 311 | 311 | * @param array $options |
| 312 | 312 | * @return string |
| 313 | 313 | */ |
| 314 | - public function navItem($title, $url='#', $options=[], $active=false) |
|
| 314 | + public function navItem($title, $url = '#', $options = [], $active = false) |
|
| 315 | 315 | { |
| 316 | 316 | $options['active'] = $active; |
| 317 | 317 | |
@@ -333,7 +333,7 @@ discard block |
||
| 333 | 333 | * @param array $options |
| 334 | 334 | * @param callable $c |
| 335 | 335 | */ |
| 336 | - public function navDropdown($title,$options=[], \Closure $c) |
|
| 336 | + public function navDropdown($title, $options = [], \Closure $c) |
|
| 337 | 337 | { |
| 338 | 338 | $classes = $this->buildClassString('has-dropdown', $options, true); |
| 339 | 339 | |
@@ -366,7 +366,7 @@ discard block |
||
| 366 | 366 | |
| 367 | 367 | //-------------------------------------------------------------------- |
| 368 | 368 | |
| 369 | - public function sideNav($options=[], \Closure $c) |
|
| 369 | + public function sideNav($options = [], \Closure $c) |
|
| 370 | 370 | { |
| 371 | 371 | $classes = $this->buildClassString('side-nav', $options, true); |
| 372 | 372 | |
@@ -392,7 +392,7 @@ discard block |
||
| 392 | 392 | * @param callable $c |
| 393 | 393 | * @return mixed |
| 394 | 394 | */ |
| 395 | - public function breadcrumb($options=[], \Closure $c) |
|
| 395 | + public function breadcrumb($options = [], \Closure $c) |
|
| 396 | 396 | { |
| 397 | 397 | list($classes, $id, $attributes) = $this->parseStandardOptions($options, 'breadcrumbs', true); |
| 398 | 398 | |
@@ -433,9 +433,9 @@ discard block |
||
| 433 | 433 | * @param array $options |
| 434 | 434 | * @return mixed |
| 435 | 435 | */ |
| 436 | - public function button($title, $style='default', $size='default', $options=[]) |
|
| 436 | + public function button($title, $style = 'default', $size = 'default', $options = []) |
|
| 437 | 437 | { |
| 438 | - $tag= "<button type='button' {classes} {id} {attributes}>{$title}</button>"; |
|
| 438 | + $tag = "<button type='button' {classes} {id} {attributes}>{$title}</button>"; |
|
| 439 | 439 | |
| 440 | 440 | return $this->renderButtonElement($title, $style, $size, $options, $tag); |
| 441 | 441 | } |
@@ -454,9 +454,9 @@ discard block |
||
| 454 | 454 | * @param array $options |
| 455 | 455 | * @return mixed |
| 456 | 456 | */ |
| 457 | - public function buttonLink($title, $url='#', $style='default', $size='default', $options=[]) |
|
| 457 | + public function buttonLink($title, $url = '#', $style = 'default', $size = 'default', $options = []) |
|
| 458 | 458 | { |
| 459 | - $class = isset($options['class']) ? $options['class'] .' button' : 'button'; |
|
| 459 | + $class = isset($options['class']) ? $options['class'].' button' : 'button'; |
|
| 460 | 460 | $options['class'] = $class; |
| 461 | 461 | |
| 462 | 462 | $tag = "<a {classes} {id} {attributes} role='button'>{$title}</a>"; |
@@ -479,7 +479,7 @@ discard block |
||
| 479 | 479 | $valid_styles = ['default', 'primary', 'success', 'info', 'warning', 'danger']; |
| 480 | 480 | $valid_sizes = ['default', 'small', 'xsmall', 'large']; |
| 481 | 481 | |
| 482 | - if (! in_array($style, $valid_styles)) |
|
| 482 | + if ( ! in_array($style, $valid_styles)) |
|
| 483 | 483 | { |
| 484 | 484 | $style = 'default'; |
| 485 | 485 | $options['attributes'][] = 'data-error="Invalid Style passed to button method."'; |
@@ -488,7 +488,7 @@ discard block |
||
| 488 | 488 | $classes = 'btn '; |
| 489 | 489 | |
| 490 | 490 | // Sizes |
| 491 | - switch($size) |
|
| 491 | + switch ($size) |
|
| 492 | 492 | { |
| 493 | 493 | case 'small': |
| 494 | 494 | $classes .= 'small '; |
@@ -536,7 +536,7 @@ discard block |
||
| 536 | 536 | // If we're in a button group we need to wrap each item in li tags. |
| 537 | 537 | if (isset($this->states['inButtonGroup'])) |
| 538 | 538 | { |
| 539 | - $tag = '<li>'. $tag .'</li>'; |
|
| 539 | + $tag = '<li>'.$tag.'</li>'; |
|
| 540 | 540 | } |
| 541 | 541 | return $tag; |
| 542 | 542 | } |
@@ -602,7 +602,7 @@ discard block |
||
| 602 | 602 | * @param callable $c |
| 603 | 603 | * @return mixed |
| 604 | 604 | */ |
| 605 | - public function buttonDropdown($title, $style='default', $size='default', $options=[], \Closure $c) |
|
| 605 | + public function buttonDropdown($title, $style = 'default', $size = 'default', $options = [], \Closure $c) |
|
| 606 | 606 | { |
| 607 | 607 | list($classes, $id, $attributes) = $this->parseStandardOptions($options, 'button split', true); |
| 608 | 608 | |
@@ -632,7 +632,7 @@ discard block |
||
| 632 | 632 | * @param bool $closable |
| 633 | 633 | * @return mixed |
| 634 | 634 | */ |
| 635 | - public function notice($content, $style='success', $closable=true, $options=[]) |
|
| 635 | + public function notice($content, $style = 'success', $closable = true, $options = []) |
|
| 636 | 636 | { |
| 637 | 637 | list($classes, $id, $attributes) = $this->parseStandardOptions($options, 'alert-box ', false); |
| 638 | 638 | |
@@ -56,7 +56,7 @@ discard block |
||
| 56 | 56 | * @param array $segments |
| 57 | 57 | * @param bool $quiet |
| 58 | 58 | */ |
| 59 | - public function run($segments=[], $quiet=false) |
|
| 59 | + public function run($segments = [], $quiet = false) |
|
| 60 | 60 | { |
| 61 | 61 | // Show an index? |
| 62 | 62 | if (empty($segments[0])) |
@@ -75,7 +75,7 @@ discard block |
||
| 75 | 75 | $this->scaffold($segments, $quiet); |
| 76 | 76 | break; |
| 77 | 77 | default: |
| 78 | - if (! $quiet) |
|
| 78 | + if ( ! $quiet) |
|
| 79 | 79 | { |
| 80 | 80 | CLI::write('Nothing to do.', 'green'); |
| 81 | 81 | } |
@@ -89,8 +89,8 @@ discard block |
||
| 89 | 89 | { |
| 90 | 90 | CLI::write("\nAvailable API Generators"); |
| 91 | 91 | |
| 92 | - CLI::write( CLI::color('install', 'yellow') .' install Creates migrations, alters config file for desired authentication' ); |
|
| 93 | - CLI::write( CLI::color('scaffold', 'yellow') .' scaffold <name> Creates basic CRUD controller, routes, and optionally API Blueprint files' ); |
|
| 92 | + CLI::write(CLI::color('install', 'yellow').' install Creates migrations, alters config file for desired authentication'); |
|
| 93 | + CLI::write(CLI::color('scaffold', 'yellow').' scaffold <name> Creates basic CRUD controller, routes, and optionally API Blueprint files'); |
|
| 94 | 94 | } |
| 95 | 95 | |
| 96 | 96 | //-------------------------------------------------------------------- |
@@ -105,7 +105,7 @@ discard block |
||
| 105 | 105 | * @param $segments |
| 106 | 106 | * @param $quiet |
| 107 | 107 | */ |
| 108 | - private function scaffold( $segments, $quiet ) |
|
| 108 | + private function scaffold($segments, $quiet) |
|
| 109 | 109 | { |
| 110 | 110 | $this->load->helper('inflector'); |
| 111 | 111 | |
@@ -118,7 +118,7 @@ discard block |
||
| 118 | 118 | |
| 119 | 119 | if (empty($resource)) |
| 120 | 120 | { |
| 121 | - $resource = strtolower( CLI::prompt('Resource name') ); |
|
| 121 | + $resource = strtolower(CLI::prompt('Resource name')); |
|
| 122 | 122 | } |
| 123 | 123 | |
| 124 | 124 | // Resources should be plural, but we'll need a singular name also. |
@@ -138,27 +138,27 @@ discard block |
||
| 138 | 138 | |
| 139 | 139 | if (empty($model)) |
| 140 | 140 | { |
| 141 | - $model = $this->detectModel( $resource_single ); |
|
| 141 | + $model = $this->detectModel($resource_single); |
|
| 142 | 142 | } |
| 143 | 143 | |
| 144 | 144 | /* |
| 145 | 145 | * Start Building |
| 146 | 146 | */ |
| 147 | - $this->destination = APPPATH .'controllers/'; |
|
| 148 | - if (! empty($version)) |
|
| 147 | + $this->destination = APPPATH.'controllers/'; |
|
| 148 | + if ( ! empty($version)) |
|
| 149 | 149 | { |
| 150 | - $this->destination .= $version .'/'; |
|
| 150 | + $this->destination .= $version.'/'; |
|
| 151 | 151 | } |
| 152 | 152 | |
| 153 | 153 | // Controller |
| 154 | - if (! $this->createController($resource_single, $resource_plural, $version) ) |
|
| 154 | + if ( ! $this->createController($resource_single, $resource_plural, $version)) |
|
| 155 | 155 | { |
| 156 | 156 | CLI::error('Unknown error creating Controller.'); |
| 157 | 157 | exit(1); |
| 158 | 158 | } |
| 159 | 159 | |
| 160 | 160 | // Language Files |
| 161 | - if (! $this->createLanguage($resource_single, $resource_plural, $version, $model) ) |
|
| 161 | + if ( ! $this->createLanguage($resource_single, $resource_plural, $version, $model)) |
|
| 162 | 162 | { |
| 163 | 163 | CLI::error('Unknown error creating Language File.'); |
| 164 | 164 | exit(1); |
@@ -167,7 +167,7 @@ discard block |
||
| 167 | 167 | // Blueprint File |
| 168 | 168 | if ($blueprint) |
| 169 | 169 | { |
| 170 | - if (! $this->createBlueprint($resource_single, $resource_plural, $version, $model) ) |
|
| 170 | + if ( ! $this->createBlueprint($resource_single, $resource_plural, $version, $model)) |
|
| 171 | 171 | { |
| 172 | 172 | CLI::error('Unknown error creating Blueprint file.'); |
| 173 | 173 | exit(1); |
@@ -175,7 +175,7 @@ discard block |
||
| 175 | 175 | } |
| 176 | 176 | |
| 177 | 177 | // Modify Routes |
| 178 | - if (! $this->addRoutes($resource_plural, $version) ) |
|
| 178 | + if ( ! $this->addRoutes($resource_plural, $version)) |
|
| 179 | 179 | { |
| 180 | 180 | CLI::error('Unknown error adding Routes.'); |
| 181 | 181 | exit(1); |
@@ -195,7 +195,7 @@ discard block |
||
| 195 | 195 | CLI::write("\nVersions are simply controller folders (i.e. controllers/v1/...)"); |
| 196 | 196 | CLI::write("(Enter 'na' for no version folder)"); |
| 197 | 197 | |
| 198 | - $version = strtolower( CLI::prompt('Version name', 'v1') ); |
|
| 198 | + $version = strtolower(CLI::prompt('Version name', 'v1')); |
|
| 199 | 199 | $version = $version == 'na' ? '' : $version; |
| 200 | 200 | |
| 201 | 201 | return $version; |
@@ -211,7 +211,7 @@ discard block |
||
| 211 | 211 | private function askBlueprint() |
| 212 | 212 | { |
| 213 | 213 | CLI::write("\nAPI Blueprint is a plain-text API documentation starter."); |
| 214 | - CLI::write("See: ". CLI::color('https://apiblueprint.org', 'light_blue')); |
|
| 214 | + CLI::write("See: ".CLI::color('https://apiblueprint.org', 'light_blue')); |
|
| 215 | 215 | |
| 216 | 216 | $make_blueprint = CLI::prompt('Create Blueprint file?', ['y', 'n']); |
| 217 | 217 | |
@@ -222,16 +222,16 @@ discard block |
||
| 222 | 222 | |
| 223 | 223 | private function detectModel($name) |
| 224 | 224 | { |
| 225 | - $model_name = ucfirst($name) .'_model.php'; |
|
| 225 | + $model_name = ucfirst($name).'_model.php'; |
|
| 226 | 226 | |
| 227 | - if (! file_exists(APPPATH .'models/'. $model_name)) |
|
| 227 | + if ( ! file_exists(APPPATH.'models/'.$model_name)) |
|
| 228 | 228 | { |
| 229 | 229 | CLI::write("\nUnable to find model named: {$model_name}"); |
| 230 | 230 | $model_name = CLI::prompt('Model filename'); |
| 231 | 231 | } |
| 232 | 232 | else |
| 233 | 233 | { |
| 234 | - CLI::write("Using model: ". CLI::color($model_name, 'yellow') ); |
|
| 234 | + CLI::write("Using model: ".CLI::color($model_name, 'yellow')); |
|
| 235 | 235 | } |
| 236 | 236 | |
| 237 | 237 | return $model_name; |
@@ -250,20 +250,20 @@ discard block |
||
| 250 | 250 | * @internal param $name |
| 251 | 251 | * |
| 252 | 252 | */ |
| 253 | - private function createController( $single, $plural, $version ) |
|
| 253 | + private function createController($single, $plural, $version) |
|
| 254 | 254 | { |
| 255 | 255 | $data = [ |
| 256 | - 'today' => date( 'Y-m-d H:ia' ), |
|
| 257 | - 'model_name' => strtolower($single) .'_model', |
|
| 256 | + 'today' => date('Y-m-d H:ia'), |
|
| 257 | + 'model_name' => strtolower($single).'_model', |
|
| 258 | 258 | 'plural' => $plural, |
| 259 | 259 | 'single' => $single, |
| 260 | 260 | 'class_name' => ucfirst($plural), |
| 261 | 261 | 'version' => $version |
| 262 | 262 | ]; |
| 263 | 263 | |
| 264 | - $destination = $this->destination . ucfirst($plural) .'.php'; |
|
| 264 | + $destination = $this->destination.ucfirst($plural).'.php'; |
|
| 265 | 265 | |
| 266 | - return $this->copyTemplate( 'controller', $destination, $data, $this->overwrite ); |
|
| 266 | + return $this->copyTemplate('controller', $destination, $data, $this->overwrite); |
|
| 267 | 267 | } |
| 268 | 268 | |
| 269 | 269 | //-------------------------------------------------------------------- |
@@ -277,7 +277,7 @@ discard block |
||
| 277 | 277 | * |
| 278 | 278 | * @return $this |
| 279 | 279 | */ |
| 280 | - private function createLanguage( $single, $plural, $version ) |
|
| 280 | + private function createLanguage($single, $plural, $version) |
|
| 281 | 281 | { |
| 282 | 282 | $data = [ |
| 283 | 283 | 'plural' => $plural, |
@@ -286,9 +286,9 @@ discard block |
||
| 286 | 286 | 'uc_plural' => ucfirst($plural), |
| 287 | 287 | ]; |
| 288 | 288 | |
| 289 | - $destination = APPPATH ."language/english/api_{$plural}_lang.php"; |
|
| 289 | + $destination = APPPATH."language/english/api_{$plural}_lang.php"; |
|
| 290 | 290 | |
| 291 | - return $this->copyTemplate( 'lang', $destination, $data, $this->overwrite ); |
|
| 291 | + return $this->copyTemplate('lang', $destination, $data, $this->overwrite); |
|
| 292 | 292 | } |
| 293 | 293 | |
| 294 | 294 | //-------------------------------------------------------------------- |
@@ -306,17 +306,17 @@ discard block |
||
| 306 | 306 | * @internal param $name |
| 307 | 307 | * |
| 308 | 308 | */ |
| 309 | - private function createBlueprint( $single, $plural, $version, $model ) |
|
| 309 | + private function createBlueprint($single, $plural, $version, $model) |
|
| 310 | 310 | { |
| 311 | 311 | $version = rtrim($version, '/'); |
| 312 | - if (! empty($version)) |
|
| 312 | + if ( ! empty($version)) |
|
| 313 | 313 | { |
| 314 | 314 | $version .= '/'; |
| 315 | 315 | } |
| 316 | 316 | |
| 317 | 317 | // Load the model so we can use the correct table to use |
| 318 | - $model = strtolower( str_replace('.php', '', $model) ); |
|
| 319 | - $this->load->model( $model, $model, true ); |
|
| 318 | + $model = strtolower(str_replace('.php', '', $model)); |
|
| 319 | + $this->load->model($model, $model, true); |
|
| 320 | 320 | |
| 321 | 321 | $obj = $this->formatObject($model); |
| 322 | 322 | |
@@ -331,11 +331,11 @@ discard block |
||
| 331 | 331 | 'formatted' => $obj |
| 332 | 332 | ]; |
| 333 | 333 | |
| 334 | - $destination = APPPATH .'docs/api/'. $version . $plural .'.md'; |
|
| 334 | + $destination = APPPATH.'docs/api/'.$version.$plural.'.md'; |
|
| 335 | 335 | |
| 336 | - $success = $this->copyTemplate( 'blueprint', $destination, $data, $this->overwrite ); |
|
| 336 | + $success = $this->copyTemplate('blueprint', $destination, $data, $this->overwrite); |
|
| 337 | 337 | |
| 338 | - if (! $this->updateTOC($plural, $version)) |
|
| 338 | + if ( ! $this->updateTOC($plural, $version)) |
|
| 339 | 339 | { |
| 340 | 340 | CLI::write("\tUnable to modify the toc file.", 'light_red'); |
| 341 | 341 | } |
@@ -353,21 +353,21 @@ discard block |
||
| 353 | 353 | * |
| 354 | 354 | * @return $this|bool |
| 355 | 355 | */ |
| 356 | - private function updateTOC( $plural, $version ) |
|
| 356 | + private function updateTOC($plural, $version) |
|
| 357 | 357 | { |
| 358 | - $path = APPPATH .'docs/_toc.ini'; |
|
| 358 | + $path = APPPATH.'docs/_toc.ini'; |
|
| 359 | 359 | |
| 360 | 360 | // We need a TOC file to exist if we're going to modify it silly. |
| 361 | - if (! file_exists($path)) |
|
| 361 | + if ( ! file_exists($path)) |
|
| 362 | 362 | { |
| 363 | - if (! $this->copyTemplate('toc', $path)) |
|
| 363 | + if ( ! $this->copyTemplate('toc', $path)) |
|
| 364 | 364 | { |
| 365 | 365 | return false; |
| 366 | 366 | } |
| 367 | 367 | } |
| 368 | 368 | |
| 369 | 369 | $version = rtrim($version, '/ '); |
| 370 | - if (! empty($version)) |
|
| 370 | + if ( ! empty($version)) |
|
| 371 | 371 | { |
| 372 | 372 | $version .= '/'; |
| 373 | 373 | } |
@@ -389,7 +389,7 @@ discard block |
||
| 389 | 389 | * |
| 390 | 390 | * @return string |
| 391 | 391 | */ |
| 392 | - private function formatObject( $model ) |
|
| 392 | + private function formatObject($model) |
|
| 393 | 393 | { |
| 394 | 394 | $fields = $this->db->field_data($this->$model->table_name); |
| 395 | 395 | |
@@ -448,14 +448,14 @@ discard block |
||
| 448 | 448 | * |
| 449 | 449 | * @return $this |
| 450 | 450 | */ |
| 451 | - private function addRoutes( $plural, $version ) |
|
| 451 | + private function addRoutes($plural, $version) |
|
| 452 | 452 | { |
| 453 | - $path = APPPATH .'config/routes.php'; |
|
| 453 | + $path = APPPATH.'config/routes.php'; |
|
| 454 | 454 | |
| 455 | 455 | $version = rtrim($version, ', '); |
| 456 | - if (! empty($version)) |
|
| 456 | + if ( ! empty($version)) |
|
| 457 | 457 | { |
| 458 | - $version .='/'; |
|
| 458 | + $version .= '/'; |
|
| 459 | 459 | } |
| 460 | 460 | |
| 461 | 461 | $content = "\$routes->resources('{$version}{$plural}');\n"; |
@@ -476,9 +476,9 @@ discard block |
||
| 476 | 476 | */ |
| 477 | 477 | private function install( ) |
| 478 | 478 | { |
| 479 | - CLI::write("Available Auth Types: ". CLI::color('basic, digest, none', 'yellow') ); |
|
| 479 | + CLI::write("Available Auth Types: ".CLI::color('basic, digest, none', 'yellow')); |
|
| 480 | 480 | |
| 481 | - $this->auth_type = trim( CLI::prompt('Auth type') ); |
|
| 481 | + $this->auth_type = trim(CLI::prompt('Auth type')); |
|
| 482 | 482 | |
| 483 | 483 | switch ($this->auth_type) |
| 484 | 484 | { |
@@ -531,24 +531,24 @@ discard block |
||
| 531 | 531 | |
| 532 | 532 | // Update the config setting |
| 533 | 533 | $content = "config['api.enable_logging'] = true;"; |
| 534 | - $this->injectIntoFile(APPPATH .'config/api.php', $content, ['regex' => "/config\['api.enable_logging']\s+=\s+[a-zA-Z]+;/u"] ); |
|
| 534 | + $this->injectIntoFile(APPPATH.'config/api.php', $content, ['regex' => "/config\['api.enable_logging']\s+=\s+[a-zA-Z]+;/u"]); |
|
| 535 | 535 | } |
| 536 | 536 | |
| 537 | 537 | //-------------------------------------------------------------------- |
| 538 | 538 | |
| 539 | 539 | |
| 540 | - private function makeMigration( $tpl, $name ) |
|
| 540 | + private function makeMigration($tpl, $name) |
|
| 541 | 541 | { |
| 542 | 542 | // Create the migration |
| 543 | 543 | $this->load->library('migration'); |
| 544 | 544 | |
| 545 | 545 | $destination = $this->migration->determine_migration_path('app', true); |
| 546 | 546 | |
| 547 | - $file = $this->migration->make_name( $name ); |
|
| 547 | + $file = $this->migration->make_name($name); |
|
| 548 | 548 | |
| 549 | - $destination = rtrim($destination, '/') .'/'. $file; |
|
| 549 | + $destination = rtrim($destination, '/').'/'.$file; |
|
| 550 | 550 | |
| 551 | - if (! $this->copyTemplate( $tpl, $destination, [], true) ) |
|
| 551 | + if ( ! $this->copyTemplate($tpl, $destination, [], true)) |
|
| 552 | 552 | { |
| 553 | 553 | CLI::error('Error creating migration file.'); |
| 554 | 554 | } |
@@ -563,11 +563,11 @@ discard block |
||
| 563 | 563 | * |
| 564 | 564 | * @param $type |
| 565 | 565 | */ |
| 566 | - private function setAuthType( $type ) |
|
| 566 | + private function setAuthType($type) |
|
| 567 | 567 | { |
| 568 | 568 | $content = "config['api.auth_type'] = '{$type}';"; |
| 569 | 569 | |
| 570 | - $this->injectIntoFile(APPPATH .'config/api.php', $content, ['regex' => "/config\['api.auth_type']\s+=\s+'[a-zA-Z]+';/u"] ); |
|
| 570 | + $this->injectIntoFile(APPPATH.'config/api.php', $content, ['regex' => "/config\['api.auth_type']\s+=\s+'[a-zA-Z]+';/u"]); |
|
| 571 | 571 | } |
| 572 | 572 | |
| 573 | 573 | //-------------------------------------------------------------------- |
@@ -47,49 +47,49 @@ discard block |
||
| 47 | 47 | |
| 48 | 48 | //-------------------------------------------------------------------- |
| 49 | 49 | |
| 50 | - public function run( $segments = [ ], $quiet = FALSE ) |
|
| 50 | + public function run($segments = [], $quiet = FALSE) |
|
| 51 | 51 | { |
| 52 | - $name = array_shift( $segments ); |
|
| 52 | + $name = array_shift($segments); |
|
| 53 | 53 | |
| 54 | - if ( empty( $name ) ) |
|
| 54 | + if (empty($name)) |
|
| 55 | 55 | { |
| 56 | - $name = CLI::prompt( 'Controller name' ); |
|
| 56 | + $name = CLI::prompt('Controller name'); |
|
| 57 | 57 | } |
| 58 | 58 | |
| 59 | 59 | // Format to CI Standards |
| 60 | - $name = ucfirst( $name ); |
|
| 60 | + $name = ucfirst($name); |
|
| 61 | 61 | |
| 62 | - if ( $quiet === FALSE ) |
|
| 62 | + if ($quiet === FALSE) |
|
| 63 | 63 | { |
| 64 | - $this->collectOptions( $name ); |
|
| 64 | + $this->collectOptions($name); |
|
| 65 | 65 | } |
| 66 | 66 | else |
| 67 | 67 | { |
| 68 | - $this->quietSetOptions( $name ); |
|
| 68 | + $this->quietSetOptions($name); |
|
| 69 | 69 | } |
| 70 | 70 | |
| 71 | 71 | $data = [ |
| 72 | 72 | 'controller_name' => $name, |
| 73 | - 'today' => date( 'Y-m-d H:ia' ) |
|
| 73 | + 'today' => date('Y-m-d H:ia') |
|
| 74 | 74 | ]; |
| 75 | 75 | |
| 76 | - $data = array_merge( $data, $this->options ); |
|
| 76 | + $data = array_merge($data, $this->options); |
|
| 77 | 77 | |
| 78 | 78 | if ($data['themed'] == 'y' || $data['themed'] === true) |
| 79 | 79 | { |
| 80 | 80 | $data['base_class'] = 'ThemedController'; |
| 81 | 81 | } |
| 82 | 82 | |
| 83 | - $destination = $this->determineOutputPath( 'controllers' ) . $name . '.php'; |
|
| 83 | + $destination = $this->determineOutputPath('controllers').$name.'.php'; |
|
| 84 | 84 | |
| 85 | - if ( ! $this->copyTemplate( 'controller', $destination, $data, $this->overwrite ) ) |
|
| 85 | + if ( ! $this->copyTemplate('controller', $destination, $data, $this->overwrite)) |
|
| 86 | 86 | { |
| 87 | - CLI::error( 'Error creating new files' ); |
|
| 87 | + CLI::error('Error creating new files'); |
|
| 88 | 88 | } |
| 89 | 89 | |
| 90 | - if ( CLI::option( 'create_views' ) && $this->options['themed'] == 'y' ) |
|
| 90 | + if (CLI::option('create_views') && $this->options['themed'] == 'y') |
|
| 91 | 91 | { |
| 92 | - $this->createViews( $name ); |
|
| 92 | + $this->createViews($name); |
|
| 93 | 93 | } |
| 94 | 94 | |
| 95 | 95 | return TRUE; |
@@ -97,20 +97,20 @@ discard block |
||
| 97 | 97 | |
| 98 | 98 | //-------------------------------------------------------------------- |
| 99 | 99 | |
| 100 | - protected function quietSetOptions( $name ) |
|
| 100 | + protected function quietSetOptions($name) |
|
| 101 | 101 | { |
| 102 | 102 | $options = CLI::getOptions(); |
| 103 | 103 | |
| 104 | - if ( ! empty( $options['model'] ) ) |
|
| 104 | + if ( ! empty($options['model'])) |
|
| 105 | 105 | { |
| 106 | 106 | $this->options['model'] = $options['model']; |
| 107 | 107 | |
| 108 | 108 | // Format per CI |
| 109 | - if ( ! empty( $this->options['model'] ) && substr( $this->options['model'], - 6 ) !== '_model' ) |
|
| 109 | + if ( ! empty($this->options['model']) && substr($this->options['model'], - 6) !== '_model') |
|
| 110 | 110 | { |
| 111 | 111 | $this->options['model'] .= '_model'; |
| 112 | 112 | } |
| 113 | - $this->options['model'] = ! empty( $this->options['model'] ) ? ucfirst( $this->options['model'] ) : NULL; |
|
| 113 | + $this->options['model'] = ! empty($this->options['model']) ? ucfirst($this->options['model']) : NULL; |
|
| 114 | 114 | |
| 115 | 115 | $this->options['themed'] = 'y'; |
| 116 | 116 | } |
@@ -120,36 +120,34 @@ discard block |
||
| 120 | 120 | |
| 121 | 121 | //-------------------------------------------------------------------- |
| 122 | 122 | |
| 123 | - protected function collectOptions( $name ) |
|
| 123 | + protected function collectOptions($name) |
|
| 124 | 124 | { |
| 125 | 125 | $options = CLI::getOptions(); |
| 126 | 126 | |
| 127 | 127 | // Model? |
| 128 | - $this->options['model'] = empty( $options['model'] ) ? |
|
| 129 | - CLI::prompt( 'Model Name? (empty is fine)' ) : |
|
| 130 | - $options['model']; |
|
| 128 | + $this->options['model'] = empty($options['model']) ? |
|
| 129 | + CLI::prompt('Model Name? (empty is fine)') : $options['model']; |
|
| 131 | 130 | |
| 132 | 131 | // Format per CI |
| 133 | - if ( ! empty( $this->options['model'] ) && substr( $this->options['model'], - 6 ) !== '_model' ) |
|
| 132 | + if ( ! empty($this->options['model']) && substr($this->options['model'], - 6) !== '_model') |
|
| 134 | 133 | { |
| 135 | 134 | $this->options['model'] .= '_model'; |
| 136 | 135 | } |
| 137 | - $this->options['model'] = ! empty( $this->options['model'] ) ? ucfirst( $this->options['model'] ) : NULL; |
|
| 136 | + $this->options['model'] = ! empty($this->options['model']) ? ucfirst($this->options['model']) : NULL; |
|
| 138 | 137 | |
| 139 | 138 | // If we're using a model, then force the use of a themed controller. |
| 140 | - if ( ! empty( $this->options['model'] ) ) |
|
| 139 | + if ( ! empty($this->options['model'])) |
|
| 141 | 140 | { |
| 142 | 141 | $options['themed'] = 'y'; |
| 143 | 142 | } |
| 144 | 143 | |
| 145 | 144 | // Themed Controller? |
| 146 | - $this->options['themed'] = empty( $options['themed'] ) ? |
|
| 147 | - CLI::prompt( 'Is a Themed Controller?', [ 'y', 'n' ] ) : |
|
| 148 | - $options['themed']; |
|
| 145 | + $this->options['themed'] = empty($options['themed']) ? |
|
| 146 | + CLI::prompt('Is a Themed Controller?', ['y', 'n']) : $options['themed']; |
|
| 149 | 147 | |
| 150 | 148 | $this->options['themed'] = $this->options['themed'] == 'y' ? TRUE : FALSE; |
| 151 | 149 | |
| 152 | - if ( $this->options['themed'] ) |
|
| 150 | + if ($this->options['themed']) |
|
| 153 | 151 | { |
| 154 | 152 | $this->options['base_class'] = 'ThemedController'; |
| 155 | 153 | } |
@@ -160,35 +158,35 @@ discard block |
||
| 160 | 158 | /** |
| 161 | 159 | * Generates the standard views for our CRUD methods. |
| 162 | 160 | */ |
| 163 | - protected function createViews( $name ) |
|
| 161 | + protected function createViews($name) |
|
| 164 | 162 | { |
| 165 | - $this->load->helper( 'inflector' ); |
|
| 163 | + $this->load->helper('inflector'); |
|
| 166 | 164 | |
| 167 | 165 | $data = [ |
| 168 | 166 | 'name' => $name, |
| 169 | 167 | 'lower_name' => strtolower($name), |
| 170 | - 'single_name' => singular( $name ), |
|
| 171 | - 'plural_name' => plural( $name ), |
|
| 168 | + 'single_name' => singular($name), |
|
| 169 | + 'plural_name' => plural($name), |
|
| 172 | 170 | 'fields' => $this->prepareFields() |
| 173 | 171 | ]; |
| 174 | 172 | |
| 175 | - $subfolder = empty( $this->module ) ? '/' . strtolower($name) : '/'. $data['lower_name']; |
|
| 173 | + $subfolder = empty($this->module) ? '/'.strtolower($name) : '/'.$data['lower_name']; |
|
| 176 | 174 | |
| 177 | 175 | // Index |
| 178 | - $destination = $this->determineOutputPath( 'views' . $subfolder ) . 'index.php'; |
|
| 179 | - $this->copyTemplate( 'view_index', $destination, $data, $this->overwrite ); |
|
| 176 | + $destination = $this->determineOutputPath('views'.$subfolder).'index.php'; |
|
| 177 | + $this->copyTemplate('view_index', $destination, $data, $this->overwrite); |
|
| 180 | 178 | |
| 181 | 179 | // Create |
| 182 | - $destination = $this->determineOutputPath( 'views' . $subfolder ) . 'create.php'; |
|
| 183 | - $this->copyTemplate( 'view_create', $destination, $data, $this->overwrite ); |
|
| 180 | + $destination = $this->determineOutputPath('views'.$subfolder).'create.php'; |
|
| 181 | + $this->copyTemplate('view_create', $destination, $data, $this->overwrite); |
|
| 184 | 182 | |
| 185 | 183 | // Show |
| 186 | - $destination = $this->determineOutputPath( 'views' . $subfolder ) . 'show.php'; |
|
| 187 | - $this->copyTemplate( 'view_show', $destination, $data, $this->overwrite ); |
|
| 184 | + $destination = $this->determineOutputPath('views'.$subfolder).'show.php'; |
|
| 185 | + $this->copyTemplate('view_show', $destination, $data, $this->overwrite); |
|
| 188 | 186 | |
| 189 | 187 | // Index |
| 190 | - $destination = $this->determineOutputPath( 'views' . $subfolder ) . 'update.php'; |
|
| 191 | - $this->copyTemplate( 'view_update', $destination, $data, $this->overwrite ); |
|
| 188 | + $destination = $this->determineOutputPath('views'.$subfolder).'update.php'; |
|
| 189 | + $this->copyTemplate('view_update', $destination, $data, $this->overwrite); |
|
| 192 | 190 | } |
| 193 | 191 | |
| 194 | 192 | //-------------------------------------------------------------------- |
@@ -199,14 +197,14 @@ discard block |
||
| 199 | 197 | */ |
| 200 | 198 | protected function prepareFields() |
| 201 | 199 | { |
| 202 | - $fields = CLI::option( 'fields' ); |
|
| 200 | + $fields = CLI::option('fields'); |
|
| 203 | 201 | |
| 204 | - if ( empty( $fields ) ) |
|
| 202 | + if (empty($fields)) |
|
| 205 | 203 | { |
| 206 | 204 | // If we have a model, we can get our fields from there |
| 207 | - if (! empty($this->options['model'])) |
|
| 205 | + if ( ! empty($this->options['model'])) |
|
| 208 | 206 | { |
| 209 | - $fields = $this->getFieldsFromModel( $this->options['model'] ); |
|
| 207 | + $fields = $this->getFieldsFromModel($this->options['model']); |
|
| 210 | 208 | |
| 211 | 209 | if (empty($fields)) |
| 212 | 210 | { |
@@ -219,15 +217,15 @@ discard block |
||
| 219 | 217 | } |
| 220 | 218 | } |
| 221 | 219 | |
| 222 | - $fields = explode( ' ', $fields ); |
|
| 220 | + $fields = explode(' ', $fields); |
|
| 223 | 221 | |
| 224 | - $new_fields = [ ]; |
|
| 222 | + $new_fields = []; |
|
| 225 | 223 | |
| 226 | - foreach ( $fields as $field ) |
|
| 224 | + foreach ($fields as $field) |
|
| 227 | 225 | { |
| 228 | - $pop = [ NULL, NULL, NULL ]; |
|
| 229 | - list( $field, $type, $size ) = array_merge( explode( ':', $field ), $pop ); |
|
| 230 | - $type = strtolower( $type ); |
|
| 226 | + $pop = [NULL, NULL, NULL]; |
|
| 227 | + list($field, $type, $size) = array_merge(explode(':', $field), $pop); |
|
| 228 | + $type = strtolower($type); |
|
| 231 | 229 | |
| 232 | 230 | // Ignore list |
| 233 | 231 | if (in_array($field, ['created_on', 'modified_on'])) |
@@ -277,16 +275,16 @@ discard block |
||
| 277 | 275 | |
| 278 | 276 | //-------------------------------------------------------------------- |
| 279 | 277 | |
| 280 | - private function getFieldsFromModel( $model ) |
|
| 278 | + private function getFieldsFromModel($model) |
|
| 281 | 279 | { |
| 282 | 280 | $this->load->model($model); |
| 283 | 281 | |
| 284 | - if (! $this->db->table_exists( $this->$model->table() )) |
|
| 282 | + if ( ! $this->db->table_exists($this->$model->table())) |
|
| 285 | 283 | { |
| 286 | 284 | return ''; |
| 287 | 285 | } |
| 288 | 286 | |
| 289 | - $fields = $this->db->field_data( $this->$model->table() ); |
|
| 287 | + $fields = $this->db->field_data($this->$model->table()); |
|
| 290 | 288 | |
| 291 | 289 | $return = ''; |
| 292 | 290 | |
@@ -294,14 +292,14 @@ discard block |
||
| 294 | 292 | // it would have been passed on the CLI |
| 295 | 293 | foreach ($fields as $field) |
| 296 | 294 | { |
| 297 | - $temp = $field->name .':'. $field->type; |
|
| 295 | + $temp = $field->name.':'.$field->type; |
|
| 298 | 296 | |
| 299 | - if (! empty($field->max_length)) |
|
| 297 | + if ( ! empty($field->max_length)) |
|
| 300 | 298 | { |
| 301 | - $temp .= ':'. $field->max_length; |
|
| 299 | + $temp .= ':'.$field->max_length; |
|
| 302 | 300 | } |
| 303 | 301 | |
| 304 | - $return .= ' '. $temp; |
|
| 302 | + $return .= ' '.$temp; |
|
| 305 | 303 | } |
| 306 | 304 | |
| 307 | 305 | return $return; |
@@ -5,9 +5,9 @@ discard block |
||
| 5 | 5 | //-------------------------------------------------------------------- |
| 6 | 6 | |
| 7 | 7 | $model_string = $model ? "'{$model}'" : 'null'; |
| 8 | -$lower_model = trim( strtolower($model_string), "' " ); |
|
| 8 | +$lower_model = trim(strtolower($model_string), "' "); |
|
| 9 | 9 | $lower_model_esc = strpos($lower_model, 'null') !== false ? 'null' : "'{$lower_model}'"; |
| 10 | -$lower_controller = strtolower($controller_name); |
|
| 10 | +$lower_controller = strtolower($controller_name); |
|
| 11 | 11 | |
| 12 | 12 | //-------------------------------------------------------------------- |
| 13 | 13 | // Build our Methods |
@@ -21,7 +21,7 @@ discard block |
||
| 21 | 21 | */ |
| 22 | 22 | $index_method = ''; |
| 23 | 23 | |
| 24 | -if (! empty($model) ) |
|
| 24 | +if ( ! empty($model)) |
|
| 25 | 25 | { |
| 26 | 26 | $index_method = <<<EOD |
| 27 | 27 | \$this->load->library('table'); |
@@ -42,7 +42,7 @@ discard block |
||
| 42 | 42 | */ |
| 43 | 43 | $create_method = ''; |
| 44 | 44 | |
| 45 | -if (! empty($model)) |
|
| 45 | +if ( ! empty($model)) |
|
| 46 | 46 | { |
| 47 | 47 | $create_method = <<<EOD |
| 48 | 48 | \$this->load->helper('form'); |
@@ -70,7 +70,7 @@ discard block |
||
| 70 | 70 | */ |
| 71 | 71 | $show_method = ''; |
| 72 | 72 | |
| 73 | -if (! empty($model)) |
|
| 73 | +if ( ! empty($model)) |
|
| 74 | 74 | { |
| 75 | 75 | $show_method = <<<EOD |
| 76 | 76 | \$item = \$this->{$lower_model}->find(\$id); |
@@ -92,7 +92,7 @@ discard block |
||
| 92 | 92 | */ |
| 93 | 93 | $update_method = ''; |
| 94 | 94 | |
| 95 | -if (! empty($model)) |
|
| 95 | +if ( ! empty($model)) |
|
| 96 | 96 | { |
| 97 | 97 | $update_method = <<<EOD |
| 98 | 98 | \$this->load->helper('form'); |
@@ -123,7 +123,7 @@ discard block |
||
| 123 | 123 | */ |
| 124 | 124 | $delete_method = ''; |
| 125 | 125 | |
| 126 | -if (! empty($model)) |
|
| 126 | +if ( ! empty($model)) |
|
| 127 | 127 | { |
| 128 | 128 | $delete_method = <<<EOD |
| 129 | 129 | if (\$this->{$lower_model}->delete(\$id)) |
@@ -13,7 +13,7 @@ |
||
| 13 | 13 | |
| 14 | 14 | foreach ($fields as $field) |
| 15 | 15 | { |
| 16 | - echo $uikit->inputWrap( humanize($field['name']), null, function() use($uikit, $field) { |
|
| 16 | + echo $uikit->inputWrap(humanize($field['name']), null, function() use($uikit, $field) { |
|
| 17 | 17 | |
| 18 | 18 | switch ($field['type']) |
| 19 | 19 | { |
@@ -10,34 +10,34 @@ |
||
| 10 | 10 | 'm' => 6, |
| 11 | 11 | 'l' => 4 |
| 12 | 12 | ]; |
| 13 | - echo $uikit->column( [ 'sizes' => $sizes ], function () use ( $uikit, $fields ) |
|
| 13 | + echo $uikit->column(['sizes' => $sizes], function() use ($uikit, $fields) |
|
| 14 | 14 | { |
| 15 | 15 | |
| 16 | - foreach ( $fields as $field ) |
|
| 16 | + foreach ($fields as $field) |
|
| 17 | 17 | { |
| 18 | 18 | |
| 19 | - echo $uikit->inputWrap( humanize( $field['name'] ), NULL, function () use ( $uikit, $field ) |
|
| 19 | + echo $uikit->inputWrap(humanize($field['name']), NULL, function() use ($uikit, $field) |
|
| 20 | 20 | { |
| 21 | 21 | |
| 22 | - switch ( $field['type'] ) |
|
| 22 | + switch ($field['type']) |
|
| 23 | 23 | { |
| 24 | 24 | case 'text': |
| 25 | - echo " <input type='text' name='{$field['name']}' class='form-control' value='@= set_value('" . $field["name"] . "', \$item->" . $field['name'] . " ) ?>' />\n"; |
|
| 25 | + echo " <input type='text' name='{$field['name']}' class='form-control' value='@= set_value('".$field["name"]."', \$item->".$field['name']." ) ?>' />\n"; |
|
| 26 | 26 | break; |
| 27 | 27 | case 'number': |
| 28 | - echo " <input type='number' name='{$field['name']}' class='form-control' value='@= set_value('" . $field["name"] . "', \$item->" . $field['name'] . " ) ?>' />\n"; |
|
| 28 | + echo " <input type='number' name='{$field['name']}' class='form-control' value='@= set_value('".$field["name"]."', \$item->".$field['name']." ) ?>' />\n"; |
|
| 29 | 29 | break; |
| 30 | 30 | case 'date': |
| 31 | - echo " <input type='date' name='{$field['name']}' class='form-control' value='@= set_value('" . $field["name"] . "', \$item->" . $field['name'] . " ) ?>' />\n"; |
|
| 31 | + echo " <input type='date' name='{$field['name']}' class='form-control' value='@= set_value('".$field["name"]."', \$item->".$field['name']." ) ?>' />\n"; |
|
| 32 | 32 | break; |
| 33 | 33 | case 'datetime': |
| 34 | - echo " <input type='datetime' name='{$field['name']}' class='form-control' value='@= set_value('" . $field["name"] . "', \$item->" . $field['name'] . " ) ?>' />\n"; |
|
| 34 | + echo " <input type='datetime' name='{$field['name']}' class='form-control' value='@= set_value('".$field["name"]."', \$item->".$field['name']." ) ?>' />\n"; |
|
| 35 | 35 | break; |
| 36 | 36 | case 'time': |
| 37 | - echo " <input type='time' name='{$field['name']}' class='form-control' value='@= set_value('" . $field["name"] . "', \$item->" . $field['name'] . " ) ?>' />\n"; |
|
| 37 | + echo " <input type='time' name='{$field['name']}' class='form-control' value='@= set_value('".$field["name"]."', \$item->".$field['name']." ) ?>' />\n"; |
|
| 38 | 38 | break; |
| 39 | 39 | case 'textarea': |
| 40 | - echo " <textarea class='form-control' name='{$field['name']}'>@= set_value('" . $field["name"] . "') ?></textarea>\n"; |
|
| 40 | + echo " <textarea class='form-control' name='{$field['name']}'>@= set_value('".$field["name"]."') ?></textarea>\n"; |
|
| 41 | 41 | break; |
| 42 | 42 | } |
| 43 | 43 | |
@@ -92,27 +92,27 @@ discard block |
||
| 92 | 92 | |
| 93 | 93 | //-------------------------------------------------------------------- |
| 94 | 94 | |
| 95 | - public function run($segments=[], $quiet=false) |
|
| 95 | + public function run($segments = [], $quiet = false) |
|
| 96 | 96 | { |
| 97 | - $name = array_shift( $segments ); |
|
| 97 | + $name = array_shift($segments); |
|
| 98 | 98 | |
| 99 | - if ( empty( $name ) ) |
|
| 99 | + if (empty($name)) |
|
| 100 | 100 | { |
| 101 | - $name = CLI::prompt( 'Migration name' ); |
|
| 101 | + $name = CLI::prompt('Migration name'); |
|
| 102 | 102 | } |
| 103 | 103 | |
| 104 | 104 | // Format to CI Standards |
| 105 | - $name = str_replace('.php', '', strtolower( $name ) ); |
|
| 105 | + $name = str_replace('.php', '', strtolower($name)); |
|
| 106 | 106 | |
| 107 | 107 | $this->detectAction($name); |
| 108 | 108 | |
| 109 | - $this->collectOptions( $name, $quiet ); |
|
| 109 | + $this->collectOptions($name, $quiet); |
|
| 110 | 110 | |
| 111 | 111 | $data = [ |
| 112 | 112 | 'name' => $name, |
| 113 | 113 | 'clean_name' => ucwords(str_replace('_', ' ', $name)), |
| 114 | - 'today' => date( 'Y-m-d H:ia' ), |
|
| 115 | - 'fields' => trim( $this->stringify( $this->fields ), ', '), |
|
| 114 | + 'today' => date('Y-m-d H:ia'), |
|
| 115 | + 'fields' => trim($this->stringify($this->fields), ', '), |
|
| 116 | 116 | 'raw_fields' => $this->fields, |
| 117 | 117 | 'action' => $this->action, |
| 118 | 118 | 'table' => $this->table, |
@@ -120,9 +120,9 @@ discard block |
||
| 120 | 120 | 'column' => $this->column |
| 121 | 121 | ]; |
| 122 | 122 | |
| 123 | - if (! empty($this->column) && array_key_exists($this->column, $this->fields)) |
|
| 123 | + if ( ! empty($this->column) && array_key_exists($this->column, $this->fields)) |
|
| 124 | 124 | { |
| 125 | - $data['column_string'] = trim( $this->stringify($this->fields[$this->column]), ', '); |
|
| 125 | + $data['column_string'] = trim($this->stringify($this->fields[$this->column]), ', '); |
|
| 126 | 126 | } |
| 127 | 127 | |
| 128 | 128 | $this->load->library('migration'); |
@@ -130,17 +130,17 @@ discard block |
||
| 130 | 130 | // todo Allow different migration "types" |
| 131 | 131 | $type = 'app'; |
| 132 | 132 | |
| 133 | - if (! empty($this->module)) |
|
| 133 | + if ( ! empty($this->module)) |
|
| 134 | 134 | { |
| 135 | - $type = 'mod:'. $this->module; |
|
| 135 | + $type = 'mod:'.$this->module; |
|
| 136 | 136 | } |
| 137 | 137 | $destination = $this->migration->determine_migration_path($type, true); |
| 138 | 138 | |
| 139 | 139 | $file = $this->migration->make_name($name); |
| 140 | 140 | |
| 141 | - $destination = rtrim($destination, '/') .'/'. $file; |
|
| 141 | + $destination = rtrim($destination, '/').'/'.$file; |
|
| 142 | 142 | |
| 143 | - if (! $this->copyTemplate( 'migration', $destination, $data, true) ) |
|
| 143 | + if ( ! $this->copyTemplate('migration', $destination, $data, true)) |
|
| 144 | 144 | { |
| 145 | 145 | CLI::error('Error creating seed file.'); |
| 146 | 146 | } |
@@ -173,7 +173,7 @@ discard block |
||
| 173 | 173 | $action = $this->actionMap[$action]; |
| 174 | 174 | } |
| 175 | 175 | |
| 176 | - if (! in_array($action, $this->allowedActions)) |
|
| 176 | + if ( ! in_array($action, $this->allowedActions)) |
|
| 177 | 177 | { |
| 178 | 178 | return; |
| 179 | 179 | } |
@@ -187,7 +187,7 @@ discard block |
||
| 187 | 187 | |
| 188 | 188 | // The name of the table is assumed to be the one |
| 189 | 189 | // prior to the $index found. |
| 190 | - $this->table = plural( implode('_', array_slice($segments, 0, $index) ) ); |
|
| 190 | + $this->table = plural(implode('_', array_slice($segments, 0, $index))); |
|
| 191 | 191 | } |
| 192 | 192 | |
| 193 | 193 | // Are we referencing a column? |
@@ -199,12 +199,12 @@ discard block |
||
| 199 | 199 | |
| 200 | 200 | //-------------------------------------------------------------------- |
| 201 | 201 | |
| 202 | - public function collectOptions($name, $quiet=false) |
|
| 202 | + public function collectOptions($name, $quiet = false) |
|
| 203 | 203 | { |
| 204 | 204 | $options = CLI::getOptions(); |
| 205 | 205 | |
| 206 | 206 | // Use existing db table? |
| 207 | - if (array_key_exists('fromdb', $options) ) |
|
| 207 | + if (array_key_exists('fromdb', $options)) |
|
| 208 | 208 | { |
| 209 | 209 | $this->readTable($this->table); |
| 210 | 210 | } |
@@ -217,10 +217,9 @@ discard block |
||
| 217 | 217 | return; |
| 218 | 218 | } |
| 219 | 219 | |
| 220 | - $fields = empty( $fields ) ? |
|
| 221 | - CLI::prompt( 'Fields? (name:type)' ) : |
|
| 222 | - $options['fields']; |
|
| 223 | - $this->fields = $this->parseFields( $fields ); |
|
| 220 | + $fields = empty($fields) ? |
|
| 221 | + CLI::prompt('Fields? (name:type)') : $options['fields']; |
|
| 222 | + $this->fields = $this->parseFields($fields); |
|
| 224 | 223 | } |
| 225 | 224 | } |
| 226 | 225 | |
@@ -244,7 +243,7 @@ discard block |
||
| 244 | 243 | $fields = []; |
| 245 | 244 | $segments = explode(' ', $str); |
| 246 | 245 | |
| 247 | - if (! count($segments)) |
|
| 246 | + if ( ! count($segments)) |
|
| 248 | 247 | { |
| 249 | 248 | return $fields; |
| 250 | 249 | } |
@@ -252,7 +251,7 @@ discard block |
||
| 252 | 251 | foreach ($segments as $segment) |
| 253 | 252 | { |
| 254 | 253 | $pop = [null, null, null]; |
| 255 | - list($field, $type, $size) = array_merge( explode(':', $segment), $pop); |
|
| 254 | + list($field, $type, $size) = array_merge(explode(':', $segment), $pop); |
|
| 256 | 255 | $type = strtolower($type); |
| 257 | 256 | |
| 258 | 257 | // Is type one of our convenience mapped items? |
@@ -261,7 +260,7 @@ discard block |
||
| 261 | 260 | $type = $this->map[$type]; |
| 262 | 261 | } |
| 263 | 262 | |
| 264 | - $f = [ 'type' => $type ]; |
|
| 263 | + $f = ['type' => $type]; |
|
| 265 | 264 | |
| 266 | 265 | // Creating a primary key? |
| 267 | 266 | if ($type == 'id') |
@@ -275,9 +274,9 @@ discard block |
||
| 275 | 274 | } |
| 276 | 275 | |
| 277 | 276 | // Constraint? |
| 278 | - if (! empty($size)) |
|
| 277 | + if ( ! empty($size)) |
|
| 279 | 278 | { |
| 280 | - $f['constraint'] = (int)$size; |
|
| 279 | + $f['constraint'] = (int) $size; |
|
| 281 | 280 | } |
| 282 | 281 | else if (array_key_exists($type, $this->defaultSizes)) |
| 283 | 282 | { |
@@ -319,7 +318,7 @@ discard block |
||
| 319 | 318 | } |
| 320 | 319 | |
| 321 | 320 | // Table exists? |
| 322 | - if (! $this->db->table_exists($table)) |
|
| 321 | + if ( ! $this->db->table_exists($table)) |
|
| 323 | 322 | { |
| 324 | 323 | return false; |
| 325 | 324 | } |
@@ -327,7 +326,7 @@ discard block |
||
| 327 | 326 | $fields = $this->db->field_data($table); |
| 328 | 327 | |
| 329 | 328 | // Any fields? |
| 330 | - if (! is_array($fields) || ! count($fields)) |
|
| 329 | + if ( ! is_array($fields) || ! count($fields)) |
|
| 331 | 330 | { |
| 332 | 331 | return false; |
| 333 | 332 | } |
@@ -336,30 +335,30 @@ discard block |
||
| 336 | 335 | |
| 337 | 336 | foreach ($fields as $field) |
| 338 | 337 | { |
| 339 | - $f = [ 'type' => $field->type ]; |
|
| 338 | + $f = ['type' => $field->type]; |
|
| 340 | 339 | |
| 341 | 340 | // Constraint |
| 342 | - if (! empty($field->max_length)) |
|
| 341 | + if ( ! empty($field->max_length)) |
|
| 343 | 342 | { |
| 344 | 343 | $f['constraint'] = $field->max_length; |
| 345 | 344 | } |
| 346 | 345 | else if (array_key_exists($field->type, $this->defaultSizes)) |
| 347 | 346 | { |
| 348 | - $f['constraint'] = $this->defaultSizes[ $field->type ]; |
|
| 347 | + $f['constraint'] = $this->defaultSizes[$field->type]; |
|
| 349 | 348 | } |
| 350 | 349 | |
| 351 | 350 | // Default |
| 352 | - if (! empty($field->default)) $f['default'] = $field->default; |
|
| 351 | + if ( ! empty($field->default)) $f['default'] = $field->default; |
|
| 353 | 352 | |
| 354 | 353 | // Primary Key? |
| 355 | - if (! empty($field->primary_key) && $field->primary_key == 1) |
|
| 354 | + if ( ! empty($field->primary_key) && $field->primary_key == 1) |
|
| 356 | 355 | { |
| 357 | 356 | $this->primary_key = $field->name; |
| 358 | 357 | $f['auto_increment'] = true; |
| 359 | 358 | $f['unsigned'] = true; |
| 360 | 359 | } |
| 361 | 360 | |
| 362 | - $new_fields[ $field->name ] = $f; |
|
| 361 | + $new_fields[$field->name] = $f; |
|
| 363 | 362 | } |
| 364 | 363 | |
| 365 | 364 | $this->fields = $new_fields; |
@@ -17,13 +17,13 @@ |
||
| 17 | 17 | \$this->dbforge->add_field(\$fields); |
| 18 | 18 | "; |
| 19 | 19 | |
| 20 | - if (! empty($primary_key)) |
|
| 20 | + if ( ! empty($primary_key)) |
|
| 21 | 21 | { |
| 22 | 22 | $up .= " \$this->dbforge->add_key('{$primary_key}', true); |
| 23 | 23 | "; |
| 24 | 24 | } |
| 25 | 25 | |
| 26 | - $up .=" \$this->dbforge->create_table('{$table}', true, config_item('migration_create_table_attr') ); |
|
| 26 | + $up .= " \$this->dbforge->create_table('{$table}', true, config_item('migration_create_table_attr') ); |
|
| 27 | 27 | "; |
| 28 | 28 | |
| 29 | 29 | $down = "\$this->dbforge->drop_table('{$table}');"; |
@@ -56,47 +56,47 @@ discard block |
||
| 56 | 56 | |
| 57 | 57 | //-------------------------------------------------------------------- |
| 58 | 58 | |
| 59 | - public function run( $segments = [ ], $quiet = false ) |
|
| 59 | + public function run($segments = [], $quiet = false) |
|
| 60 | 60 | { |
| 61 | - $name = array_shift( $segments ); |
|
| 61 | + $name = array_shift($segments); |
|
| 62 | 62 | |
| 63 | 63 | $options = CLI::getOptions(); |
| 64 | 64 | |
| 65 | - $this->options['table_name'] = array_shift( $segments ); |
|
| 65 | + $this->options['table_name'] = array_shift($segments); |
|
| 66 | 66 | |
| 67 | - if ( empty( $name ) ) |
|
| 67 | + if (empty($name)) |
|
| 68 | 68 | { |
| 69 | - $name = CLI::prompt( 'Model name' ); |
|
| 69 | + $name = CLI::prompt('Model name'); |
|
| 70 | 70 | } |
| 71 | 71 | |
| 72 | 72 | // Format to CI Standards |
| 73 | - if ( substr( $name, - 6 ) !== '_model' ) |
|
| 73 | + if (substr($name, - 6) !== '_model') |
|
| 74 | 74 | { |
| 75 | 75 | $name .= '_model'; |
| 76 | 76 | } |
| 77 | - $name = ucfirst( $name ); |
|
| 77 | + $name = ucfirst($name); |
|
| 78 | 78 | |
| 79 | - if ( $quiet === false ) |
|
| 79 | + if ($quiet === false) |
|
| 80 | 80 | { |
| 81 | - $this->collectOptions( $name, $options ); |
|
| 81 | + $this->collectOptions($name, $options); |
|
| 82 | 82 | } |
| 83 | 83 | else |
| 84 | 84 | { |
| 85 | - $this->quietSetOptions( $name, $options ); |
|
| 85 | + $this->quietSetOptions($name, $options); |
|
| 86 | 86 | } |
| 87 | 87 | |
| 88 | 88 | $data = [ |
| 89 | 89 | 'model_name' => $name, |
| 90 | - 'today' => date( 'Y-m-d H:ia' ) |
|
| 90 | + 'today' => date('Y-m-d H:ia') |
|
| 91 | 91 | ]; |
| 92 | 92 | |
| 93 | - $data = array_merge( $data, $this->options ); |
|
| 93 | + $data = array_merge($data, $this->options); |
|
| 94 | 94 | |
| 95 | - $destination = $this->determineOutputPath( 'models' ) . $name . '.php'; |
|
| 95 | + $destination = $this->determineOutputPath('models').$name.'.php'; |
|
| 96 | 96 | |
| 97 | - if ( ! $this->copyTemplate( 'model', $destination, $data, $this->overwrite ) ) |
|
| 97 | + if ( ! $this->copyTemplate('model', $destination, $data, $this->overwrite)) |
|
| 98 | 98 | { |
| 99 | - CLI::error( 'Error creating new files' ); |
|
| 99 | + CLI::error('Error creating new files'); |
|
| 100 | 100 | } |
| 101 | 101 | |
| 102 | 102 | return TRUE; |
@@ -107,70 +107,67 @@ discard block |
||
| 107 | 107 | /* |
| 108 | 108 | * Customizes our settings |
| 109 | 109 | */ |
| 110 | - protected function collectOptions( $model_name, $options=[] ) |
|
| 110 | + protected function collectOptions($model_name, $options = []) |
|
| 111 | 111 | { |
| 112 | - $this->load->helper( 'inflector' ); |
|
| 112 | + $this->load->helper('inflector'); |
|
| 113 | 113 | |
| 114 | 114 | // Table Name? |
| 115 | - if ( empty( $this->options['table_name'] ) ) |
|
| 115 | + if (empty($this->options['table_name'])) |
|
| 116 | 116 | { |
| 117 | - $this->options['table_name'] = empty( $options['table'] ) ? |
|
| 118 | - CLI::prompt( 'Table name', plural( strtolower( str_replace( '_model', '', $model_name ) ) ) ) : |
|
| 119 | - $options['table']; |
|
| 117 | + $this->options['table_name'] = empty($options['table']) ? |
|
| 118 | + CLI::prompt('Table name', plural(strtolower(str_replace('_model', '', $model_name)))) : $options['table']; |
|
| 120 | 119 | } |
| 121 | 120 | |
| 122 | - $this->options['fields'] = $this->table_info( $this->options['table_name'], $options ); |
|
| 121 | + $this->options['fields'] = $this->table_info($this->options['table_name'], $options); |
|
| 123 | 122 | |
| 124 | 123 | // Primary Key |
| 125 | 124 | if (empty($this->options['primary_key'])) |
| 126 | 125 | { |
| 127 | - $this->options['primary_key'] = empty( $options['primary_key'] ) ? |
|
| 128 | - CLI::prompt( 'Primary Key', 'id' ) : |
|
| 129 | - $options['primary_key']; |
|
| 126 | + $this->options['primary_key'] = empty($options['primary_key']) ? |
|
| 127 | + CLI::prompt('Primary Key', 'id') : $options['primary_key']; |
|
| 130 | 128 | } |
| 131 | 129 | |
| 132 | - $this->options['protected'] = [ $this->options['primary_key'] ]; |
|
| 130 | + $this->options['protected'] = [$this->options['primary_key']]; |
|
| 133 | 131 | |
| 134 | 132 | // Set Created? |
| 135 | - if ( empty( $options['set_created'] ) ) |
|
| 133 | + if (empty($options['set_created'])) |
|
| 136 | 134 | { |
| 137 | - $ans = CLI::prompt( 'Set Created date?', [ 'y', 'n' ] ); |
|
| 138 | - if ( $ans == 'n' ) |
|
| 135 | + $ans = CLI::prompt('Set Created date?', ['y', 'n']); |
|
| 136 | + if ($ans == 'n') |
|
| 139 | 137 | { |
| 140 | 138 | $this->options['set_created'] = FALSE; |
| 141 | 139 | } |
| 142 | 140 | } |
| 143 | 141 | |
| 144 | 142 | // Set Modified? |
| 145 | - if ( empty( $options['set_modified'] ) ) |
|
| 143 | + if (empty($options['set_modified'])) |
|
| 146 | 144 | { |
| 147 | - $ans = CLI::prompt( 'Set Modified date?', [ 'y', 'n' ] ); |
|
| 148 | - if ( $ans == 'n' ) |
|
| 145 | + $ans = CLI::prompt('Set Modified date?', ['y', 'n']); |
|
| 146 | + if ($ans == 'n') |
|
| 149 | 147 | { |
| 150 | 148 | $this->options['set_modified'] = FALSE; |
| 151 | 149 | } |
| 152 | 150 | } |
| 153 | 151 | |
| 154 | 152 | // Date Format |
| 155 | - $this->options['date_format'] = empty( $options['date_format'] ) ? |
|
| 156 | - CLI::prompt( 'Date Format?', [ 'datetime', 'date', 'int' ] ) : |
|
| 157 | - $options['date_format']; |
|
| 153 | + $this->options['date_format'] = empty($options['date_format']) ? |
|
| 154 | + CLI::prompt('Date Format?', ['datetime', 'date', 'int']) : $options['date_format']; |
|
| 158 | 155 | |
| 159 | 156 | // Log User? |
| 160 | - if ( empty( $options['log_user'] ) ) |
|
| 157 | + if (empty($options['log_user'])) |
|
| 161 | 158 | { |
| 162 | - $ans = CLI::prompt( 'Log User actions?', [ 'y', 'n' ] ); |
|
| 163 | - if ( $ans == 'y' ) |
|
| 159 | + $ans = CLI::prompt('Log User actions?', ['y', 'n']); |
|
| 160 | + if ($ans == 'y') |
|
| 164 | 161 | { |
| 165 | 162 | $this->options['log_user'] = TRUE; |
| 166 | 163 | } |
| 167 | 164 | } |
| 168 | 165 | |
| 169 | 166 | // Soft Deletes |
| 170 | - if ( empty( $options['soft_delete'] ) ) |
|
| 167 | + if (empty($options['soft_delete'])) |
|
| 171 | 168 | { |
| 172 | - $ans = CLI::prompt( 'Use Soft Deletes?', [ 'y', 'n' ] ); |
|
| 173 | - if ( $ans == 'n' ) |
|
| 169 | + $ans = CLI::prompt('Use Soft Deletes?', ['y', 'n']); |
|
| 170 | + if ($ans == 'n') |
|
| 174 | 171 | { |
| 175 | 172 | $this->options['soft_delete'] = false; |
| 176 | 173 | } |
@@ -180,21 +177,21 @@ discard block |
||
| 180 | 177 | |
| 181 | 178 | //-------------------------------------------------------------------- |
| 182 | 179 | |
| 183 | - protected function quietSetOptions( $model_name, $options=[] ) |
|
| 180 | + protected function quietSetOptions($model_name, $options = []) |
|
| 184 | 181 | { |
| 185 | - $this->load->helper( 'inflector' ); |
|
| 182 | + $this->load->helper('inflector'); |
|
| 186 | 183 | |
| 187 | 184 | if (empty($this->options['table_name'])) |
| 188 | 185 | { |
| 189 | - $this->options['table_name'] = plural( strtolower( str_replace( '_model', '', $model_name ) ) ); |
|
| 186 | + $this->options['table_name'] = plural(strtolower(str_replace('_model', '', $model_name))); |
|
| 190 | 187 | } |
| 191 | 188 | |
| 192 | 189 | // Try to set it from the database first, |
| 193 | 190 | // otherwise, try to pull from fields |
| 194 | - $this->options['fields'] = $this->table_info( $this->options['table_name'], $options ); |
|
| 191 | + $this->options['fields'] = $this->table_info($this->options['table_name'], $options); |
|
| 195 | 192 | |
| 196 | - $this->options['primary_key'] = ! empty( $this->options['primary_key'] ) ? $this->options['primary_key'] : 'id'; |
|
| 197 | - $this->options['protected'] = [ $this->options['primary_key'] ]; |
|
| 193 | + $this->options['primary_key'] = ! empty($this->options['primary_key']) ? $this->options['primary_key'] : 'id'; |
|
| 194 | + $this->options['protected'] = [$this->options['primary_key']]; |
|
| 198 | 195 | } |
| 199 | 196 | |
| 200 | 197 | //-------------------------------------------------------------------- |
@@ -206,12 +203,12 @@ discard block |
||
| 206 | 203 | * |
| 207 | 204 | * @return mixed An array of fields or false if the table does not exist |
| 208 | 205 | */ |
| 209 | - protected function table_info( $table_name, $options=[] ) |
|
| 206 | + protected function table_info($table_name, $options = []) |
|
| 210 | 207 | { |
| 211 | 208 | $this->load->database(); |
| 212 | 209 | |
| 213 | 210 | // Check whether the table exists in this database |
| 214 | - if ( ! $this->db->table_exists( $table_name ) ) |
|
| 211 | + if ( ! $this->db->table_exists($table_name)) |
|
| 215 | 212 | { |
| 216 | 213 | if (empty($options['fields'])) |
| 217 | 214 | { |
@@ -222,12 +219,12 @@ discard block |
||
| 222 | 219 | } |
| 223 | 220 | else |
| 224 | 221 | { |
| 225 | - $fields = $this->db->field_data( $table_name ); |
|
| 222 | + $fields = $this->db->field_data($table_name); |
|
| 226 | 223 | } |
| 227 | 224 | |
| 228 | 225 | // There may be something wrong or the database driver may not return |
| 229 | 226 | // field data |
| 230 | - if ( empty( $fields ) ) |
|
| 227 | + if (empty($fields)) |
|
| 231 | 228 | { |
| 232 | 229 | return FALSE; |
| 233 | 230 | } |
@@ -237,9 +234,9 @@ discard block |
||
| 237 | 234 | $this->options['use_soft_deletes'] = false; |
| 238 | 235 | |
| 239 | 236 | // Use the primary key if the table has one already set. |
| 240 | - foreach ( $fields as $field ) |
|
| 237 | + foreach ($fields as $field) |
|
| 241 | 238 | { |
| 242 | - if ( ! empty( $field->primary_key ) && $field->primary_key == 1 ) |
|
| 239 | + if ( ! empty($field->primary_key) && $field->primary_key == 1) |
|
| 243 | 240 | { |
| 244 | 241 | $this->options['primary_key'] = $field->name; |
| 245 | 242 | } |
@@ -261,7 +258,7 @@ discard block |
||
| 261 | 258 | } |
| 262 | 259 | |
| 263 | 260 | // Set our validation rules based on these fields |
| 264 | - $this->options['rules'] = $this->buildValidationRules( $fields ); |
|
| 261 | + $this->options['rules'] = $this->buildValidationRules($fields); |
|
| 265 | 262 | |
| 266 | 263 | return $fields; |
| 267 | 264 | } |
@@ -274,20 +271,20 @@ discard block |
||
| 274 | 271 | */ |
| 275 | 272 | protected function parseFieldString($fields) |
| 276 | 273 | { |
| 277 | - if ( empty( $fields ) ) |
|
| 274 | + if (empty($fields)) |
|
| 278 | 275 | { |
| 279 | 276 | return NULL; |
| 280 | 277 | } |
| 281 | 278 | |
| 282 | - $fields = explode( ' ', $fields ); |
|
| 279 | + $fields = explode(' ', $fields); |
|
| 283 | 280 | |
| 284 | - $new_fields = [ ]; |
|
| 281 | + $new_fields = []; |
|
| 285 | 282 | |
| 286 | - foreach ( $fields as $field ) |
|
| 283 | + foreach ($fields as $field) |
|
| 287 | 284 | { |
| 288 | - $pop = [ NULL, NULL, NULL ]; |
|
| 289 | - list( $field, $type, $size ) = array_merge( explode( ':', $field ), $pop ); |
|
| 290 | - $type = strtolower( $type ); |
|
| 285 | + $pop = [NULL, NULL, NULL]; |
|
| 286 | + list($field, $type, $size) = array_merge(explode(':', $field), $pop); |
|
| 287 | + $type = strtolower($type); |
|
| 291 | 288 | |
| 292 | 289 | // Strings |
| 293 | 290 | if (in_array($type, ['char', 'varchar', 'string'])) |
@@ -328,7 +325,7 @@ discard block |
||
| 328 | 325 | |
| 329 | 326 | // Convert to objects |
| 330 | 327 | array_walk($new_fields, function(&$item, $key) { |
| 331 | - $item = (object)$item; |
|
| 328 | + $item = (object) $item; |
|
| 332 | 329 | }); |
| 333 | 330 | |
| 334 | 331 | return $new_fields; |
@@ -345,7 +342,7 @@ discard block |
||
| 345 | 342 | * |
| 346 | 343 | * @return array |
| 347 | 344 | */ |
| 348 | - public function buildValidationrules($fields=[]) |
|
| 345 | + public function buildValidationrules($fields = []) |
|
| 349 | 346 | { |
| 350 | 347 | if (empty($fields) || ! is_array($fields) || ! count($fields)) |
| 351 | 348 | { |
@@ -390,7 +387,7 @@ discard block |
||
| 390 | 387 | break; |
| 391 | 388 | } |
| 392 | 389 | |
| 393 | - if (! empty($field->max_length)) |
|
| 390 | + if ( ! empty($field->max_length)) |
|
| 394 | 391 | { |
| 395 | 392 | $rule[] = "max_length[{$field->max_length}]"; |
| 396 | 393 | } |