@@ -101,8 +101,8 @@ discard block |
||
| 101 | 101 | */ |
| 102 | 102 | public function __construct() |
| 103 | 103 | { |
| 104 | - $this->storagePath = PATH_STORAGE . 'images' . DIRECTORY_SEPARATOR; |
|
| 105 | - $this->imageNotFoundFilename = $this->storagePath . 'not-found.jpg'; |
|
| 104 | + $this->storagePath = PATH_STORAGE.'images'.DIRECTORY_SEPARATOR; |
|
| 105 | + $this->imageNotFoundFilename = $this->storagePath.'not-found.jpg'; |
|
| 106 | 106 | } |
| 107 | 107 | |
| 108 | 108 | // ------------------------------------------------------------------------ |
@@ -122,57 +122,57 @@ discard block |
||
| 122 | 122 | |
| 123 | 123 | $this->imageFilePath = $this->imageNotFoundFilename; |
| 124 | 124 | |
| 125 | - $this->imageSize[ 'width' ] = $this->input->get('width'); |
|
| 126 | - $this->imageSize[ 'height' ] = $this->input->get('height'); |
|
| 125 | + $this->imageSize['width'] = $this->input->get('width'); |
|
| 126 | + $this->imageSize['height'] = $this->input->get('height'); |
|
| 127 | 127 | $this->imageScale = $this->input->get('scale'); |
| 128 | 128 | $this->imageQuality = $this->input->get('quality'); |
| 129 | 129 | $this->imageCrop = $this->input->get('crop'); |
| 130 | 130 | |
| 131 | 131 | if (false !== ($key = array_search('crop', $segments))) { |
| 132 | 132 | $this->imageCrop = true; |
| 133 | - unset($segments[ $key ]); |
|
| 133 | + unset($segments[$key]); |
|
| 134 | 134 | $segments = array_values($segments); |
| 135 | 135 | } |
| 136 | 136 | |
| 137 | 137 | if (count($segments) == 1) { |
| 138 | - $this->imageFilePath = $this->storagePath . end($segments); |
|
| 138 | + $this->imageFilePath = $this->storagePath.end($segments); |
|
| 139 | 139 | } elseif (count($segments) >= 2) { |
| 140 | - if (preg_match("/(\d+)(x)(\d+)/", $segments[ count($segments) - 2 ], $matches)) { |
|
| 141 | - $this->imageSize[ 'width' ] = $matches[ 1 ]; |
|
| 142 | - $this->imageSize[ 'height' ] = $matches[ 3 ]; |
|
| 140 | + if (preg_match("/(\d+)(x)(\d+)/", $segments[count($segments) - 2], $matches)) { |
|
| 141 | + $this->imageSize['width'] = $matches[1]; |
|
| 142 | + $this->imageSize['height'] = $matches[3]; |
|
| 143 | 143 | |
| 144 | 144 | if (count($segments) == 2) { |
| 145 | - $this->imageFilePath = $this->storagePath . end($segments); |
|
| 145 | + $this->imageFilePath = $this->storagePath.end($segments); |
|
| 146 | 146 | } else { |
| 147 | - $this->imageFilePath = $this->storagePath . implode(DIRECTORY_SEPARATOR, |
|
| 147 | + $this->imageFilePath = $this->storagePath.implode(DIRECTORY_SEPARATOR, |
|
| 148 | 148 | array_slice($segments, 0, |
| 149 | - count($segments) - 2)) . DIRECTORY_SEPARATOR . end($segments); |
|
| 149 | + count($segments) - 2)).DIRECTORY_SEPARATOR.end($segments); |
|
| 150 | 150 | } |
| 151 | - } elseif (preg_match("/(\d+)(p)/", $segments[ count($segments) - 2 ], |
|
| 152 | - $matches) or is_numeric($segments[ count($segments) - 2 ]) |
|
| 151 | + } elseif (preg_match("/(\d+)(p)/", $segments[count($segments) - 2], |
|
| 152 | + $matches) or is_numeric($segments[count($segments) - 2]) |
|
| 153 | 153 | ) { |
| 154 | - $this->imageScale = isset($matches[ 1 ]) ? $matches[ 1 ] : $segments[ count($segments) - 2 ]; |
|
| 154 | + $this->imageScale = isset($matches[1]) ? $matches[1] : $segments[count($segments) - 2]; |
|
| 155 | 155 | if (count($segments) == 2) { |
| 156 | - $this->imageFilePath = $this->storagePath . end($segments); |
|
| 156 | + $this->imageFilePath = $this->storagePath.end($segments); |
|
| 157 | 157 | } else { |
| 158 | - $this->imageFilePath = $this->storagePath . implode(DIRECTORY_SEPARATOR, |
|
| 158 | + $this->imageFilePath = $this->storagePath.implode(DIRECTORY_SEPARATOR, |
|
| 159 | 159 | array_slice($segments, 0, |
| 160 | - count($segments) - 2)) . DIRECTORY_SEPARATOR . end($segments); |
|
| 160 | + count($segments) - 2)).DIRECTORY_SEPARATOR.end($segments); |
|
| 161 | 161 | } |
| 162 | 162 | } else { |
| 163 | - $this->imageFilePath = $this->storagePath . implode(DIRECTORY_SEPARATOR, $segments); |
|
| 163 | + $this->imageFilePath = $this->storagePath.implode(DIRECTORY_SEPARATOR, $segments); |
|
| 164 | 164 | } |
| 165 | 165 | } |
| 166 | 166 | |
| 167 | 167 | $imageFilePath = $this->imageFilePath; |
| 168 | - $extensions[ 0 ] = pathinfo($imageFilePath, PATHINFO_EXTENSION); |
|
| 168 | + $extensions[0] = pathinfo($imageFilePath, PATHINFO_EXTENSION); |
|
| 169 | 169 | |
| 170 | 170 | for ($i = 0; $i < 2; $i++) { |
| 171 | 171 | $extension = pathinfo($imageFilePath, PATHINFO_EXTENSION); |
| 172 | 172 | |
| 173 | 173 | if ($extension !== '') { |
| 174 | - $extensions[ $i ] = $extension; |
|
| 175 | - $imageFilePath = str_replace('.' . $extensions[ $i ], '', $imageFilePath); |
|
| 174 | + $extensions[$i] = $extension; |
|
| 175 | + $imageFilePath = str_replace('.'.$extensions[$i], '', $imageFilePath); |
|
| 176 | 176 | } |
| 177 | 177 | } |
| 178 | 178 | |
@@ -184,22 +184,22 @@ discard block |
||
| 184 | 184 | ]; |
| 185 | 185 | |
| 186 | 186 | if (count($extensions) == 2) { |
| 187 | - $this->imageFilePath = $imageFilePath . '.' . $extensions[ 1 ]; |
|
| 187 | + $this->imageFilePath = $imageFilePath.'.'.$extensions[1]; |
|
| 188 | 188 | } |
| 189 | 189 | |
| 190 | 190 | if (array_key_exists($extension = reset($extensions), $mimes)) { |
| 191 | - $this->imageFileMime = $mimes[ $extension ]; |
|
| 191 | + $this->imageFileMime = $mimes[$extension]; |
|
| 192 | 192 | } elseif (array_key_exists($extension = pathinfo($this->imageFilePath, PATHINFO_EXTENSION), $mimes)) { |
| 193 | - $this->imageFileMime = $mimes[ $extension ]; |
|
| 193 | + $this->imageFileMime = $mimes[$extension]; |
|
| 194 | 194 | } |
| 195 | 195 | |
| 196 | - if ( ! is_file($this->imageFilePath)) { |
|
| 196 | + if (!is_file($this->imageFilePath)) { |
|
| 197 | 197 | $this->imageFilePath = $this->imageNotFoundFilename; |
| 198 | 198 | } |
| 199 | 199 | |
| 200 | - if ( ! empty($this->imageScale)) { |
|
| 200 | + if (!empty($this->imageScale)) { |
|
| 201 | 201 | $this->scale(); |
| 202 | - } elseif ( ! empty($this->imageSize[ 'width' ]) || ! empty($this->imageSize[ 'height' ])) { |
|
| 202 | + } elseif (!empty($this->imageSize['width']) || !empty($this->imageSize['height'])) { |
|
| 203 | 203 | $this->resize(); |
| 204 | 204 | } else { |
| 205 | 205 | $this->original(); |
@@ -217,13 +217,13 @@ discard block |
||
| 217 | 217 | { |
| 218 | 218 | $config = config('image', true); |
| 219 | 219 | |
| 220 | - if ( ! empty($this->imageQuality)) { |
|
| 220 | + if (!empty($this->imageQuality)) { |
|
| 221 | 221 | $config->offsetSet('quality', intval($this->imageQuality)); |
| 222 | 222 | } |
| 223 | 223 | |
| 224 | 224 | if ($config->cached === true) { |
| 225 | 225 | if ($this->imageFilePath !== $this->imageNotFoundFilename) { |
| 226 | - $cacheImageKey = 'image-' . $this->imageScale . '-' . str_replace($this->storagePath, '', |
|
| 226 | + $cacheImageKey = 'image-'.$this->imageScale.'-'.str_replace($this->storagePath, '', |
|
| 227 | 227 | $this->imageFilePath); |
| 228 | 228 | |
| 229 | 229 | if (cache()->hasItemPool('images')) { |
@@ -267,14 +267,14 @@ discard block |
||
| 267 | 267 | { |
| 268 | 268 | $config = config('image', true); |
| 269 | 269 | |
| 270 | - if ( ! empty($this->imageQuality)) { |
|
| 270 | + if (!empty($this->imageQuality)) { |
|
| 271 | 271 | $config->offsetSet('quality', intval($this->imageQuality)); |
| 272 | 272 | } |
| 273 | 273 | |
| 274 | 274 | if ($config->cached === true) { |
| 275 | 275 | if ($this->imageFilePath !== $this->imageNotFoundFilename) { |
| 276 | - $cacheImageKey = 'image-' . ($this->input->get('crop') ? 'crop-' : '') . implode('x', |
|
| 277 | - $this->imageSize) . '-' . str_replace($this->storagePath, '', $this->imageFilePath); |
|
| 276 | + $cacheImageKey = 'image-'.($this->input->get('crop') ? 'crop-' : '').implode('x', |
|
| 277 | + $this->imageSize).'-'.str_replace($this->storagePath, '', $this->imageFilePath); |
|
| 278 | 278 | |
| 279 | 279 | if (cache()->hasItemPool('images')) { |
| 280 | 280 | $cacheItemPool = cache()->getItemPool('images'); |
@@ -289,8 +289,8 @@ discard block |
||
| 289 | 289 | } else { |
| 290 | 290 | $manipulation = new Manipulation($config); |
| 291 | 291 | $manipulation->setImageFile($this->imageFilePath); |
| 292 | - $manipulation->resizeImage($this->imageSize[ 'width' ], $this->imageSize[ 'height' ], |
|
| 293 | - (bool)$this->imageCrop); |
|
| 292 | + $manipulation->resizeImage($this->imageSize['width'], $this->imageSize['height'], |
|
| 293 | + (bool) $this->imageCrop); |
|
| 294 | 294 | $cacheItemPool->save(new Item($cacheImageKey, $manipulation->getBlobImage(), false)); |
| 295 | 295 | |
| 296 | 296 | $manipulation->displayImage(intval($this->imageQuality), $this->imageFileMime); |
@@ -302,7 +302,7 @@ discard block |
||
| 302 | 302 | |
| 303 | 303 | $manipulation = new Manipulation($config); |
| 304 | 304 | $manipulation->setImageFile($this->imageFilePath); |
| 305 | - $manipulation->resizeImage($this->imageSize[ 'width' ], $this->imageSize[ 'height' ], (bool)$this->imageCrop); |
|
| 305 | + $manipulation->resizeImage($this->imageSize['width'], $this->imageSize['height'], (bool) $this->imageCrop); |
|
| 306 | 306 | $manipulation->displayImage(intval($this->imageQuality), $this->imageFileMime); |
| 307 | 307 | exit(EXIT_SUCCESS); |
| 308 | 308 | } |
@@ -318,7 +318,7 @@ discard block |
||
| 318 | 318 | { |
| 319 | 319 | $config = config('image', true); |
| 320 | 320 | |
| 321 | - if ( ! empty($this->imageQuality)) { |
|
| 321 | + if (!empty($this->imageQuality)) { |
|
| 322 | 322 | $config->offsetSet('quality', intval($this->imageQuality)); |
| 323 | 323 | } |
| 324 | 324 | |
@@ -79,12 +79,12 @@ discard block |
||
| 79 | 79 | $download = false; |
| 80 | 80 | if (false !== ($key = array_search('download', $segments))) { |
| 81 | 81 | $download = true; |
| 82 | - unset($segments[ $key ]); |
|
| 82 | + unset($segments[$key]); |
|
| 83 | 83 | $segments = array_values($segments); |
| 84 | 84 | } |
| 85 | 85 | |
| 86 | 86 | if (count($segments)) { |
| 87 | - $filePath = $this->directoryPath . implode(DIRECTORY_SEPARATOR, $segments); |
|
| 87 | + $filePath = $this->directoryPath.implode(DIRECTORY_SEPARATOR, $segments); |
|
| 88 | 88 | if (is_file($filePath)) { |
| 89 | 89 | if ($download) { |
| 90 | 90 | $downloader = new Downloader($filePath); |
@@ -94,10 +94,10 @@ discard block |
||
| 94 | 94 | ->download(); |
| 95 | 95 | } else { |
| 96 | 96 | $fileInfo = new SplFileInfo($filePath); |
| 97 | - header('Content-Disposition: filename=' . $fileInfo->getFilename()); |
|
| 97 | + header('Content-Disposition: filename='.$fileInfo->getFilename()); |
|
| 98 | 98 | header('Content-Transfer-Encoding: binary'); |
| 99 | - header('Last-Modified: ' . gmdate('D, d M Y H:i:s', time()) . ' GMT'); |
|
| 100 | - header('Content-Type: ' . $fileInfo->getMime()); |
|
| 99 | + header('Last-Modified: '.gmdate('D, d M Y H:i:s', time()).' GMT'); |
|
| 100 | + header('Content-Type: '.$fileInfo->getMime()); |
|
| 101 | 101 | echo @readfile($filePath); |
| 102 | 102 | exit(EXIT_SUCCESS); |
| 103 | 103 | } |
@@ -38,7 +38,7 @@ |
||
| 38 | 38 | { |
| 39 | 39 | if (services()->has('csrfProtection')) { |
| 40 | 40 | if (hash_equals(input()->server('REQUEST_METHOD'), 'POST')) { |
| 41 | - if ( ! services()->get('csrfProtection')->verify()) { |
|
| 41 | + if (!services()->get('csrfProtection')->verify()) { |
|
| 42 | 42 | output()->sendError(403, [ |
| 43 | 43 | 'message' => language()->getLine('403_INVALID_CSRF'), |
| 44 | 44 | ]); |
@@ -39,7 +39,7 @@ |
||
| 39 | 39 | public function handle(ServerRequestInterface $request) |
| 40 | 40 | { |
| 41 | 41 | // Try to get from cache |
| 42 | - $cacheKey = 'o2output_' . underscore(server_request()->getUri()->segments->__toString()); |
|
| 42 | + $cacheKey = 'o2output_'.underscore(server_request()->getUri()->segments->__toString()); |
|
| 43 | 43 | |
| 44 | 44 | $cacheHandle = cache()->getItemPool('default'); |
| 45 | 45 | |
@@ -35,7 +35,7 @@ |
||
| 35 | 35 | protected function filter($type, $offset = null, $filter = FILTER_DEFAULT) |
| 36 | 36 | { |
| 37 | 37 | if (services()->has('xssProtection')) { |
| 38 | - if ( ! services()->get('xssProtection')->verify()) { |
|
| 38 | + if (!services()->get('xssProtection')->verify()) { |
|
| 39 | 39 | $string = parent::filter($type, $offset, $filter); |
| 40 | 40 | |
| 41 | 41 | if (is_string($string)) { |
@@ -32,7 +32,7 @@ discard block |
||
| 32 | 32 | { |
| 33 | 33 | parent::__construct(); |
| 34 | 34 | |
| 35 | - if(services()->has('csrfProtection')) { |
|
| 35 | + if (services()->has('csrfProtection')) { |
|
| 36 | 36 | $this->addHeader('X-CSRF-TOKEN', services()->get('csrfProtection')->getToken()); |
| 37 | 37 | } |
| 38 | 38 | } |
@@ -76,11 +76,11 @@ discard block |
||
| 76 | 76 | } |
| 77 | 77 | |
| 78 | 78 | foreach ($filePaths as $filePath) { |
| 79 | - if (is_file($filePath . $filename . '.phtml')) { |
|
| 80 | - return $filePath . $filename . '.phtml'; |
|
| 79 | + if (is_file($filePath.$filename.'.phtml')) { |
|
| 80 | + return $filePath.$filename.'.phtml'; |
|
| 81 | 81 | break; |
| 82 | - } elseif (is_file($filePath . 'errors' . DIRECTORY_SEPARATOR . $filename . '.phtml')) { |
|
| 83 | - return $filePath . 'errors' . DIRECTORY_SEPARATOR . $filename . '.phtml'; |
|
| 82 | + } elseif (is_file($filePath.'errors'.DIRECTORY_SEPARATOR.$filename.'.phtml')) { |
|
| 83 | + return $filePath.'errors'.DIRECTORY_SEPARATOR.$filename.'.phtml'; |
|
| 84 | 84 | break; |
| 85 | 85 | } |
| 86 | 86 | } |
@@ -148,14 +148,14 @@ discard block |
||
| 148 | 148 | $error = new ErrorException($errorMessage, $errorSeverity, $errorFile, $errorLine, $errorContext); |
| 149 | 149 | |
| 150 | 150 | // Logged the error |
| 151 | - if(services()->has('logger')) { |
|
| 151 | + if (services()->has('logger')) { |
|
| 152 | 152 | logger()->error( |
| 153 | 153 | implode( |
| 154 | 154 | ' ', |
| 155 | 155 | [ |
| 156 | - '[ ' . $error->getStringSeverity() . ' ] ', |
|
| 156 | + '[ '.$error->getStringSeverity().' ] ', |
|
| 157 | 157 | $error->getMessage(), |
| 158 | - $error->getFile() . ':' . $error->getLine(), |
|
| 158 | + $error->getFile().':'.$error->getLine(), |
|
| 159 | 159 | ] |
| 160 | 160 | ) |
| 161 | 161 | ); |
@@ -171,9 +171,9 @@ discard block |
||
| 171 | 171 | $this->send(implode( |
| 172 | 172 | ' ', |
| 173 | 173 | [ |
| 174 | - '[ ' . $error->getStringSeverity() . ' ] ', |
|
| 174 | + '[ '.$error->getStringSeverity().' ] ', |
|
| 175 | 175 | $error->getMessage(), |
| 176 | - $error->getFile() . ':' . $error->getLine(), |
|
| 176 | + $error->getFile().':'.$error->getLine(), |
|
| 177 | 177 | ] |
| 178 | 178 | )); |
| 179 | 179 | exit(EXIT_ERROR); |
@@ -215,30 +215,30 @@ discard block |
||
| 215 | 215 | */ |
| 216 | 216 | public function sendError($code = 204, $vars = null, $headers = []) |
| 217 | 217 | { |
| 218 | - $languageKey = $code . '_' . error_code_string($code); |
|
| 218 | + $languageKey = $code.'_'.error_code_string($code); |
|
| 219 | 219 | |
| 220 | 220 | $error = [ |
| 221 | 221 | 'code' => $code, |
| 222 | - 'title' => language()->getLine($languageKey . '_TITLE'), |
|
| 223 | - 'message' => language()->getLine($languageKey . '_MESSAGE'), |
|
| 222 | + 'title' => language()->getLine($languageKey.'_TITLE'), |
|
| 223 | + 'message' => language()->getLine($languageKey.'_MESSAGE'), |
|
| 224 | 224 | ]; |
| 225 | 225 | |
| 226 | 226 | $this->statusCode = $code; |
| 227 | - $this->reasonPhrase = $error[ 'title' ]; |
|
| 227 | + $this->reasonPhrase = $error['title']; |
|
| 228 | 228 | |
| 229 | 229 | if (is_string($vars)) { |
| 230 | 230 | $vars = ['message' => $vars]; |
| 231 | - } elseif (is_array($vars) and empty($vars[ 'message' ])) { |
|
| 232 | - $vars[ 'message' ] = $error[ 'message' ]; |
|
| 231 | + } elseif (is_array($vars) and empty($vars['message'])) { |
|
| 232 | + $vars['message'] = $error['message']; |
|
| 233 | 233 | } |
| 234 | 234 | |
| 235 | - if (isset($vars[ 'message' ])) { |
|
| 236 | - $error[ 'message' ] = $vars[ 'message' ]; |
|
| 235 | + if (isset($vars['message'])) { |
|
| 236 | + $error['message'] = $vars['message']; |
|
| 237 | 237 | } |
| 238 | 238 | |
| 239 | 239 | if (is_ajax() or $this->mimeType !== 'text/html') { |
| 240 | 240 | $this->statusCode = $code; |
| 241 | - $this->reasonPhrase = $error[ 'title' ]; |
|
| 241 | + $this->reasonPhrase = $error['title']; |
|
| 242 | 242 | $this->send($vars); |
| 243 | 243 | |
| 244 | 244 | exit(EXIT_ERROR); |
@@ -225,7 +225,7 @@ discard block |
||
| 225 | 225 | |
| 226 | 226 | if (method_exists($db, 'hasTable')) { |
| 227 | 227 | // SQL Migrate Setup |
| 228 | - if ( ! $db->hasTable('sys_migrations')) { |
|
| 228 | + if (!$db->hasTable('sys_migrations')) { |
|
| 229 | 229 | $forge = $db->getForge(); |
| 230 | 230 | $forge->createTable('sys_migrations', [ |
| 231 | 231 | 'id' => [ |
@@ -320,7 +320,7 @@ discard block |
||
| 320 | 320 | public function register() |
| 321 | 321 | { |
| 322 | 322 | $batch = $this->getLatestBatch(); |
| 323 | - $files = glob(PATH_DATABASE . "migrations/*.php"); |
|
| 323 | + $files = glob(PATH_DATABASE."migrations/*.php"); |
|
| 324 | 324 | |
| 325 | 325 | foreach ($files as $filename) { |
| 326 | 326 | $sets = [ |
@@ -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 | |
@@ -347,7 +347,7 @@ discard block |
||
| 347 | 347 | */ |
| 348 | 348 | protected function getFilename($filename) |
| 349 | 349 | { |
| 350 | - return str_replace(PATH_DATABASE . 'migrations' . DIRECTORY_SEPARATOR, '', $filename); |
|
| 350 | + return str_replace(PATH_DATABASE.'migrations'.DIRECTORY_SEPARATOR, '', $filename); |
|
| 351 | 351 | } |
| 352 | 352 | |
| 353 | 353 | // ------------------------------------------------------------------------ |
@@ -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 | // ------------------------------------------------------------------------ |
@@ -400,7 +400,7 @@ discard block |
||
| 400 | 400 | $batch = 1; |
| 401 | 401 | if ($result = $this->qb->table('sys_migrations')->max('batch', 'lastBatch')->get()) { |
| 402 | 402 | if ($result->count()) { |
| 403 | - $batch = (int)$result->first()->lastBatch; |
|
| 403 | + $batch = (int) $result->first()->lastBatch; |
|
| 404 | 404 | } |
| 405 | 405 | } |
| 406 | 406 | |
@@ -411,7 +411,7 @@ discard block |
||
| 411 | 411 | $this->model->register(); |
| 412 | 412 | } elseif (method_exists($db, 'hasCollection')) { |
| 413 | 413 | // NoSQL Migrate Setup |
| 414 | - if ( ! $db->hasCollection('sys_migrations')) { |
|
| 414 | + if (!$db->hasCollection('sys_migrations')) { |
|
| 415 | 415 | // Coming Soon |
| 416 | 416 | } |
| 417 | 417 | } |
@@ -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,10 +560,10 @@ 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( |
@@ -573,9 +573,9 @@ discard block |
||
| 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 | } |
@@ -55,14 +55,14 @@ discard block |
||
| 55 | 55 | } |
| 56 | 56 | |
| 57 | 57 | if (strpos($this->optionPath, 'Commanders') === false) { |
| 58 | - $filePath = $this->optionPath . 'Commanders' . DIRECTORY_SEPARATOR . $this->optionFilename; |
|
| 58 | + $filePath = $this->optionPath.'Commanders'.DIRECTORY_SEPARATOR.$this->optionFilename; |
|
| 59 | 59 | } else { |
| 60 | - $filePath = $this->optionPath . $this->optionFilename; |
|
| 60 | + $filePath = $this->optionPath.$this->optionFilename; |
|
| 61 | 61 | } |
| 62 | 62 | |
| 63 | - $fileDirectory = dirname($filePath) . DIRECTORY_SEPARATOR; |
|
| 63 | + $fileDirectory = dirname($filePath).DIRECTORY_SEPARATOR; |
|
| 64 | 64 | |
| 65 | - if ( ! is_dir($fileDirectory)) { |
|
| 65 | + if (!is_dir($fileDirectory)) { |
|
| 66 | 66 | mkdir($fileDirectory, 0777, true); |
| 67 | 67 | } |
| 68 | 68 | |
@@ -82,19 +82,19 @@ discard block |
||
| 82 | 82 | |
| 83 | 83 | $classNamespace = loader()->getDirNamespace( |
| 84 | 84 | $namespaceDirectory |
| 85 | - ) . 'Commanders' . (empty($subNamespace) |
|
| 85 | + ).'Commanders'.(empty($subNamespace) |
|
| 86 | 86 | ? null |
| 87 | 87 | : str_replace( |
| 88 | 88 | '/', |
| 89 | 89 | '\\', |
| 90 | 90 | $subNamespace |
| 91 | - )) . '\\'; |
|
| 91 | + )).'\\'; |
|
| 92 | 92 | |
| 93 | - $vars[ 'CREATE_DATETIME' ] = date('d/m/Y H:m'); |
|
| 94 | - $vars[ 'NAMESPACE' ] = trim($classNamespace, '\\'); |
|
| 95 | - $vars[ 'PACKAGE' ] = '\\' . trim($classNamespace, '\\'); |
|
| 96 | - $vars[ 'CLASS' ] = $className; |
|
| 97 | - $vars[ 'FILEPATH' ] = $filePath; |
|
| 93 | + $vars['CREATE_DATETIME'] = date('d/m/Y H:m'); |
|
| 94 | + $vars['NAMESPACE'] = trim($classNamespace, '\\'); |
|
| 95 | + $vars['PACKAGE'] = '\\'.trim($classNamespace, '\\'); |
|
| 96 | + $vars['CLASS'] = $className; |
|
| 97 | + $vars['FILEPATH'] = $filePath; |
|
| 98 | 98 | |
| 99 | 99 | $phpTemplate = <<<PHPTEMPLATE |
| 100 | 100 | <?php |
@@ -102,23 +102,23 @@ discard block |
||
| 102 | 102 | |
| 103 | 103 | $className = studlycase($this->optionFilename); |
| 104 | 104 | |
| 105 | - if(empty($this->optionFileVersion)) { |
|
| 106 | - $filename = date('YmdHis') . '_' . underscore($this->optionFilename); |
|
| 105 | + if (empty($this->optionFileVersion)) { |
|
| 106 | + $filename = date('YmdHis').'_'.underscore($this->optionFilename); |
|
| 107 | 107 | } else { |
| 108 | - $filename = $this->optionFileVersion . '_' . underscore($this->optionFilename); |
|
| 108 | + $filename = $this->optionFileVersion.'_'.underscore($this->optionFilename); |
|
| 109 | 109 | } |
| 110 | 110 | |
| 111 | - $filePath = PATH_DATABASE . 'migrations' . DIRECTORY_SEPARATOR; |
|
| 111 | + $filePath = PATH_DATABASE.'migrations'.DIRECTORY_SEPARATOR; |
|
| 112 | 112 | |
| 113 | - if( ! empty($this->optionPath) ) { |
|
| 114 | - $filePath = $filePath . $this->optionPath; |
|
| 113 | + if (!empty($this->optionPath)) { |
|
| 114 | + $filePath = $filePath.$this->optionPath; |
|
| 115 | 115 | } |
| 116 | 116 | |
| 117 | - $filePath = $filePath . $filename; |
|
| 117 | + $filePath = $filePath.$filename; |
|
| 118 | 118 | |
| 119 | - $fileDirectory = dirname($filePath) . DIRECTORY_SEPARATOR; |
|
| 119 | + $fileDirectory = dirname($filePath).DIRECTORY_SEPARATOR; |
|
| 120 | 120 | |
| 121 | - if ( ! is_dir($fileDirectory)) { |
|
| 121 | + if (!is_dir($fileDirectory)) { |
|
| 122 | 122 | mkdir($fileDirectory, 0777, true); |
| 123 | 123 | } |
| 124 | 124 | |
@@ -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\Reactor\Models\Sql\Migration'; |
|
| 136 | + $vars['CREATE_DATETIME'] = date('d/m/Y H:m'); |
|
| 137 | + $vars['BASE_MIGRATION'] = 'O2System\Reactor\Models\Sql\Migration'; |
|
| 138 | 138 | |
| 139 | - if($this->optionNoSql) { |
|
| 140 | - $vars[ 'BASE_MIGRATION' ] = 'O2System\Reactor\Models\NoSql\Migration'; |
|
| 139 | + if ($this->optionNoSql) { |
|
| 140 | + $vars['BASE_MIGRATION'] = 'O2System\Reactor\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 |