@@ -42,7 +42,7 @@ discard block |
||
| 42 | 42 | */ |
| 43 | 43 | public function &__get($property) |
| 44 | 44 | { |
| 45 | - $get[ $property ] = false; |
|
| 45 | + $get[$property] = false; |
|
| 46 | 46 | |
| 47 | 47 | // CodeIgniter property aliasing |
| 48 | 48 | if ($property === 'load') { |
@@ -50,16 +50,16 @@ discard block |
||
| 50 | 50 | } |
| 51 | 51 | |
| 52 | 52 | if (services()->has($property)) { |
| 53 | - $get[ $property ] = services()->get($property); |
|
| 53 | + $get[$property] = services()->get($property); |
|
| 54 | 54 | } elseif (o2system()->__isset($property)) { |
| 55 | - $get[ $property ] = o2system()->__get($property); |
|
| 55 | + $get[$property] = o2system()->__get($property); |
|
| 56 | 56 | } elseif ($property === 'model') { |
| 57 | - $get[ $property ] = models('controller'); |
|
| 57 | + $get[$property] = models('controller'); |
|
| 58 | 58 | } elseif ($property === 'services' || $property === 'libraries') { |
| 59 | - $get[ $property ] = services(); |
|
| 59 | + $get[$property] = services(); |
|
| 60 | 60 | } |
| 61 | 61 | |
| 62 | - return $get[ $property ]; |
|
| 62 | + return $get[$property]; |
|
| 63 | 63 | } |
| 64 | 64 | |
| 65 | 65 | // ------------------------------------------------------------------------ |
@@ -49,7 +49,7 @@ discard block |
||
| 49 | 49 | $this->handleExtensionRequest(); |
| 50 | 50 | } else { |
| 51 | 51 | $uriPath = urldecode( |
| 52 | - parse_url($_SERVER[ 'REQUEST_URI' ], PHP_URL_PATH) |
|
| 52 | + parse_url($_SERVER['REQUEST_URI'], PHP_URL_PATH) |
|
| 53 | 53 | ); |
| 54 | 54 | |
| 55 | 55 | $uriPathParts = explode('public/', $uriPath); |
@@ -307,10 +307,10 @@ discard block |
||
| 307 | 307 | */ |
| 308 | 308 | public function handleAppRequest(FrameworkModuleDataStructure $app) |
| 309 | 309 | { |
| 310 | - foreach(['','modules', 'plugins'] as $additionalSegment) { |
|
| 311 | - $segments = [ $this->uri->segments->first() ]; |
|
| 310 | + foreach (['', 'modules', 'plugins'] as $additionalSegment) { |
|
| 311 | + $segments = [$this->uri->segments->first()]; |
|
| 312 | 312 | |
| 313 | - if( ! empty($additionalSegment)) { |
|
| 313 | + if ( ! empty($additionalSegment)) { |
|
| 314 | 314 | array_unshift($segments, $additionalSegment); |
| 315 | 315 | } |
| 316 | 316 | |
@@ -342,11 +342,11 @@ discard block |
||
| 342 | 342 | $uriRoutedSegments = array_diff($uriSegments, |
| 343 | 343 | array_slice($uriSegments, ($numOfUriSegments - $i))); |
| 344 | 344 | |
| 345 | - if(count($uriRoutedSegments)) { |
|
| 346 | - if($module instanceof FrameworkModuleDataStructure) { |
|
| 345 | + if (count($uriRoutedSegments)) { |
|
| 346 | + if ($module instanceof FrameworkModuleDataStructure) { |
|
| 347 | 347 | $moduleSegments = $module->getSegments(); |
| 348 | 348 | |
| 349 | - if(count($moduleSegments)) { |
|
| 349 | + if (count($moduleSegments)) { |
|
| 350 | 350 | $uriRoutedSegments = array_merge($moduleSegments, $uriRoutedSegments); |
| 351 | 351 | } |
| 352 | 352 | } |
@@ -438,7 +438,7 @@ discard block |
||
| 438 | 438 | if (class_exists($controllerClassName)) { |
| 439 | 439 | $this->addresses->any( |
| 440 | 440 | '/', |
| 441 | - function () use ($controllerClassName) { |
|
| 441 | + function() use ($controllerClassName) { |
|
| 442 | 442 | return new $controllerClassName(); |
| 443 | 443 | } |
| 444 | 444 | ); |
@@ -453,7 +453,7 @@ discard block |
||
| 453 | 453 | if (class_exists($controllerClassName)) { |
| 454 | 454 | $this->addresses->any( |
| 455 | 455 | '/', |
| 456 | - function () use ($controllerClassName) { |
|
| 456 | + function() use ($controllerClassName) { |
|
| 457 | 457 | return new $controllerClassName(); |
| 458 | 458 | } |
| 459 | 459 | ); |
@@ -505,8 +505,8 @@ discard block |
||
| 505 | 505 | ); |
| 506 | 506 | } elseif (preg_match("/([a-zA-Z0-9\\\]+)(@)([a-zA-Z0-9\\\]+)/", $closure, $matches)) { |
| 507 | 507 | $this->setController( |
| 508 | - (new KernelControllerDataStructure($matches[ 1 ])) |
|
| 509 | - ->setRequestMethod($matches[ 3 ]), |
|
| 508 | + (new KernelControllerDataStructure($matches[1])) |
|
| 509 | + ->setRequestMethod($matches[3]), |
|
| 510 | 510 | $uriSegments |
| 511 | 511 | ); |
| 512 | 512 | } elseif (presenter()->theme->use === true) { |
@@ -330,7 +330,7 @@ discard block |
||
| 330 | 330 | 'batch' => $batch, |
| 331 | 331 | ]; |
| 332 | 332 | |
| 333 | - $this->insertOrUpdate($sets, ['filename' => $sets[ 'filename' ]]); |
|
| 333 | + $this->insertOrUpdate($sets, ['filename' => $sets['filename']]); |
|
| 334 | 334 | } |
| 335 | 335 | } |
| 336 | 336 | |
@@ -366,7 +366,7 @@ discard block |
||
| 366 | 366 | $timestamp = filemtime($filename); |
| 367 | 367 | preg_match('/\d{4}[-]?\d{2}[-]?\d{2}[-]?\d{2}[-]?\d{2}[-]?\d{2}/', $filename, $matches); |
| 368 | 368 | |
| 369 | - $timestamp = count($matches) ? strtotime($matches[ 0 ]) : $timestamp; |
|
| 369 | + $timestamp = count($matches) ? strtotime($matches[0]) : $timestamp; |
|
| 370 | 370 | |
| 371 | 371 | return date('Y-m-d H:i:s', $timestamp); |
| 372 | 372 | } |
@@ -387,7 +387,7 @@ discard block |
||
| 387 | 387 | $version = 'v0.0.0'; |
| 388 | 388 | preg_match('/v\d*[.]?\d*[.]\d*/', $filename, $matches); |
| 389 | 389 | |
| 390 | - return count($matches) ? $matches[ 0 ] : $version; |
|
| 390 | + return count($matches) ? $matches[0] : $version; |
|
| 391 | 391 | } |
| 392 | 392 | |
| 393 | 393 | // ------------------------------------------------------------------------ |
@@ -424,13 +424,13 @@ discard block |
||
| 424 | 424 | */ |
| 425 | 425 | public function import() |
| 426 | 426 | { |
| 427 | - if( ! empty($this->optionSql)) { |
|
| 428 | - $filePath = PATH_DATABASE . str_replace(['/','\\'], DIRECTORY_SEPARATOR, $this->optionSql); |
|
| 427 | + if ( ! empty($this->optionSql)) { |
|
| 428 | + $filePath = PATH_DATABASE . str_replace(['/', '\\'], DIRECTORY_SEPARATOR, $this->optionSql); |
|
| 429 | 429 | |
| 430 | - if(is_file($filePath)) { |
|
| 430 | + if (is_file($filePath)) { |
|
| 431 | 431 | $sqlStatement = file_get_contents($filePath); |
| 432 | 432 | |
| 433 | - if($this->model->db->query($sqlStatement)) { |
|
| 433 | + if ($this->model->db->query($sqlStatement)) { |
|
| 434 | 434 | |
| 435 | 435 | } else { |
| 436 | 436 | |
@@ -446,9 +446,9 @@ discard block |
||
| 446 | 446 | */ |
| 447 | 447 | public function latest() |
| 448 | 448 | { |
| 449 | - if($result = $this->model->findWhere(['batch' => $this->model->getLatestBatch()])) { |
|
| 450 | - if($result->count()) { |
|
| 451 | - foreach($result as $row) { |
|
| 449 | + if ($result = $this->model->findWhere(['batch' => $this->model->getLatestBatch()])) { |
|
| 450 | + if ($result->count()) { |
|
| 451 | + foreach ($result as $row) { |
|
| 452 | 452 | $this->run($row->filename, 'up'); |
| 453 | 453 | } |
| 454 | 454 | } |
@@ -466,17 +466,17 @@ discard block |
||
| 466 | 466 | $requestBatch = ($latestBatch - 1); |
| 467 | 467 | $requestBatch = $requestBatch < 1 ? 1 : $requestBatch; |
| 468 | 468 | |
| 469 | - if( ! empty($this->optionBatch) ) { |
|
| 469 | + if ( ! empty($this->optionBatch)) { |
|
| 470 | 470 | $requestBatch = $this->optionBatch; |
| 471 | 471 | } |
| 472 | 472 | |
| 473 | 473 | $batches = range($requestBatch, $latestBatch, 1); |
| 474 | 474 | $batches = array_reverse($batches); |
| 475 | 475 | |
| 476 | - foreach($batches as $batch) { |
|
| 477 | - if($result = $this->model->findWhere(['batch' => $batch])) { |
|
| 478 | - if($result->count()) { |
|
| 479 | - foreach($result as $row) { |
|
| 476 | + foreach ($batches as $batch) { |
|
| 477 | + if ($result = $this->model->findWhere(['batch' => $batch])) { |
|
| 478 | + if ($result->count()) { |
|
| 479 | + foreach ($result as $row) { |
|
| 480 | 480 | $this->run($row->filename, 'down'); |
| 481 | 481 | $this->run($row->filename, 'up'); |
| 482 | 482 | } |
@@ -496,10 +496,10 @@ discard block |
||
| 496 | 496 | $batches = range(1, $batch, 1); |
| 497 | 497 | $batches = array_reverse($batches); |
| 498 | 498 | |
| 499 | - foreach($batches as $batch) { |
|
| 500 | - if($result = $this->model->findWhere(['batch' => $batch])) { |
|
| 501 | - if($result->count()) { |
|
| 502 | - foreach($result as $row) { |
|
| 499 | + foreach ($batches as $batch) { |
|
| 500 | + if ($result = $this->model->findWhere(['batch' => $batch])) { |
|
| 501 | + if ($result->count()) { |
|
| 502 | + foreach ($result as $row) { |
|
| 503 | 503 | $this->run($row->filename, 'down'); |
| 504 | 504 | $this->run($row->filename, 'up'); |
| 505 | 505 | } |
@@ -515,9 +515,9 @@ discard block |
||
| 515 | 515 | */ |
| 516 | 516 | public function fresh() |
| 517 | 517 | { |
| 518 | - if($result = $this->model->findWhere(['batch' => 1])) { |
|
| 519 | - if($result->count()) { |
|
| 520 | - foreach($result as $row) { |
|
| 518 | + if ($result = $this->model->findWhere(['batch' => 1])) { |
|
| 519 | + if ($result->count()) { |
|
| 520 | + foreach ($result as $row) { |
|
| 521 | 521 | $this->run($row->filename, 'up'); |
| 522 | 522 | } |
| 523 | 523 | } |
@@ -538,13 +538,13 @@ discard block |
||
| 538 | 538 | protected function run($filename, $method = 'up') |
| 539 | 539 | { |
| 540 | 540 | $filePaths = [ |
| 541 | - PATH_DATABASE . 'migrations' . DIRECTORY_SEPARATOR . str_replace(['/','\\'], DIRECTORY_SEPARATOR, $filename), |
|
| 542 | - PATH_DATABASE . str_replace(['/','\\'], DIRECTORY_SEPARATOR, $filename) |
|
| 541 | + PATH_DATABASE . 'migrations' . DIRECTORY_SEPARATOR . str_replace(['/', '\\'], DIRECTORY_SEPARATOR, $filename), |
|
| 542 | + PATH_DATABASE . str_replace(['/', '\\'], DIRECTORY_SEPARATOR, $filename) |
|
| 543 | 543 | ]; |
| 544 | 544 | |
| 545 | - foreach($filePaths as $filePath) { |
|
| 546 | - if(is_file($filePath)) { |
|
| 547 | - if(pathinfo($filePath, PATHINFO_EXTENSION) == 'php') { |
|
| 545 | + foreach ($filePaths as $filePath) { |
|
| 546 | + if (is_file($filePath)) { |
|
| 547 | + if (pathinfo($filePath, PATHINFO_EXTENSION) == 'php') { |
|
| 548 | 548 | require_once($filePath); |
| 549 | 549 | $filename = pathinfo($filePath, PATHINFO_FILENAME); |
| 550 | 550 | $filename = explode('_', $filename); |
@@ -560,22 +560,22 @@ discard block |
||
| 560 | 560 | ->setNewLinesAfter(1) |
| 561 | 561 | ); |
| 562 | 562 | |
| 563 | - if(class_exists($className)) { |
|
| 563 | + if (class_exists($className)) { |
|
| 564 | 564 | $migration = new $className(); |
| 565 | 565 | |
| 566 | - if(method_exists($migration, $method)) { |
|
| 566 | + if (method_exists($migration, $method)) { |
|
| 567 | 567 | call_user_func([$migration, $method]); |
| 568 | 568 | |
| 569 | 569 | output()->write( |
| 570 | 570 | (new Format()) |
| 571 | 571 | ->setContextualClass(Format::SUCCESS) |
| 572 | - ->setString(language()->getLine('CLI_MIGRATION_RUN_'.strtoupper($method).'_SUCCESS', [$filename])) |
|
| 572 | + ->setString(language()->getLine('CLI_MIGRATION_RUN_' . strtoupper($method) . '_SUCCESS', [$filename])) |
|
| 573 | 573 | ->setNewLinesAfter(1) |
| 574 | 574 | ); |
| 575 | 575 | |
| 576 | - if($method === 'up') { |
|
| 577 | - if(method_exists($migration, 'seed')) { |
|
| 578 | - if($this->optionSeed) { |
|
| 576 | + if ($method === 'up') { |
|
| 577 | + if (method_exists($migration, 'seed')) { |
|
| 578 | + if ($this->optionSeed) { |
|
| 579 | 579 | call_user_func([$migration, 'seed']); |
| 580 | 580 | |
| 581 | 581 | output()->write( |
@@ -589,10 +589,10 @@ discard block |
||
| 589 | 589 | } |
| 590 | 590 | } |
| 591 | 591 | } |
| 592 | - } elseif(pathinfo($filePath, PATHINFO_EXTENSION) == 'sql') { |
|
| 592 | + } elseif (pathinfo($filePath, PATHINFO_EXTENSION) == 'sql') { |
|
| 593 | 593 | $sqlStatement = file_get_contents($filePath); |
| 594 | 594 | |
| 595 | - if($this->model->db->query($sqlStatement)) { |
|
| 595 | + if ($this->model->db->query($sqlStatement)) { |
|
| 596 | 596 | output()->write( |
| 597 | 597 | (new Format()) |
| 598 | 598 | ->setContextualClass(Format::SUCCESS) |
@@ -621,7 +621,7 @@ discard block |
||
| 621 | 621 | */ |
| 622 | 622 | public function execute() |
| 623 | 623 | { |
| 624 | - if($this->optionFilename) { |
|
| 624 | + if ($this->optionFilename) { |
|
| 625 | 625 | $this->run($this->optionFilename); |
| 626 | 626 | } |
| 627 | 627 | } |
@@ -102,7 +102,7 @@ discard block |
||
| 102 | 102 | |
| 103 | 103 | $className = studlycase($this->optionFilename); |
| 104 | 104 | |
| 105 | - if(empty($this->optionFileVersion)) { |
|
| 105 | + if (empty($this->optionFileVersion)) { |
|
| 106 | 106 | $filename = date('YmdHis') . '_' . underscore($this->optionFilename); |
| 107 | 107 | } else { |
| 108 | 108 | $filename = $this->optionFileVersion . '_' . underscore($this->optionFilename); |
@@ -110,7 +110,7 @@ discard block |
||
| 110 | 110 | |
| 111 | 111 | $filePath = PATH_DATABASE . 'migrations' . DIRECTORY_SEPARATOR; |
| 112 | 112 | |
| 113 | - if( ! empty($this->optionPath) ) { |
|
| 113 | + if ( ! empty($this->optionPath)) { |
|
| 114 | 114 | $filePath = $filePath . $this->optionPath; |
| 115 | 115 | } |
| 116 | 116 | |
@@ -133,15 +133,15 @@ discard block |
||
| 133 | 133 | exit(EXIT_ERROR); |
| 134 | 134 | } |
| 135 | 135 | |
| 136 | - $vars[ 'CREATE_DATETIME' ] = date('d/m/Y H:m'); |
|
| 137 | - $vars[ 'BASE_MIGRATION' ] = 'O2System\Framework\Models\Sql\Migration'; |
|
| 136 | + $vars['CREATE_DATETIME'] = date('d/m/Y H:m'); |
|
| 137 | + $vars['BASE_MIGRATION'] = 'O2System\Framework\Models\Sql\Migration'; |
|
| 138 | 138 | |
| 139 | - if($this->optionNoSql) { |
|
| 140 | - $vars[ 'BASE_MIGRATION' ] = 'O2System\Framework\Models\NoSql\Migration'; |
|
| 139 | + if ($this->optionNoSql) { |
|
| 140 | + $vars['BASE_MIGRATION'] = 'O2System\Framework\Models\NoSql\Migration'; |
|
| 141 | 141 | } |
| 142 | 142 | |
| 143 | - $vars[ 'CLASS' ] = $className; |
|
| 144 | - $vars[ 'FILEPATH' ] = $filePath; |
|
| 143 | + $vars['CLASS'] = $className; |
|
| 144 | + $vars['FILEPATH'] = $filePath; |
|
| 145 | 145 | |
| 146 | 146 | $phpTemplate = <<<PHPTEMPLATE |
| 147 | 147 | <?php |