@@ -55,7 +55,7 @@ discard block |
||
| 55 | 55 | $args = func_get_args(); |
| 56 | 56 | |
| 57 | 57 | if ($countArgs = count($args)) { |
| 58 | - if(services()->has('config')) { |
|
| 58 | + if (services()->has('config')) { |
|
| 59 | 59 | $config = services('config'); |
| 60 | 60 | |
| 61 | 61 | if ($countArgs == 1) { |
@@ -82,7 +82,7 @@ discard block |
||
| 82 | 82 | */ |
| 83 | 83 | function cache() |
| 84 | 84 | { |
| 85 | - if(services()->has('cache')) { |
|
| 85 | + if (services()->has('cache')) { |
|
| 86 | 86 | return services()->get('cache'); |
| 87 | 87 | } |
| 88 | 88 | |
@@ -102,7 +102,7 @@ discard block |
||
| 102 | 102 | */ |
| 103 | 103 | function hooks() |
| 104 | 104 | { |
| 105 | - if(services()->has('hooks')) { |
|
| 105 | + if (services()->has('hooks')) { |
|
| 106 | 106 | return services()->get('hooks'); |
| 107 | 107 | } |
| 108 | 108 | |
@@ -141,7 +141,7 @@ discard block |
||
| 141 | 141 | $args = func_get_args(); |
| 142 | 142 | |
| 143 | 143 | if (count($args)) { |
| 144 | - return o2system()->models->get($args[ 0 ]); |
|
| 144 | + return o2system()->models->get($args[0]); |
|
| 145 | 145 | } |
| 146 | 146 | |
| 147 | 147 | return o2system()->models; |
@@ -163,7 +163,7 @@ discard block |
||
| 163 | 163 | $args = func_get_args(); |
| 164 | 164 | |
| 165 | 165 | if (count($args)) { |
| 166 | - return o2system()->modules->getModule($args[ 0 ]); |
|
| 166 | + return o2system()->modules->getModule($args[0]); |
|
| 167 | 167 | } |
| 168 | 168 | |
| 169 | 169 | return o2system()->modules; |
@@ -201,8 +201,8 @@ discard block |
||
| 201 | 201 | $args = func_get_args(); |
| 202 | 202 | |
| 203 | 203 | if (count($args)) { |
| 204 | - if(isset($_SESSION[ $args[0] ])) { |
|
| 205 | - return $_SESSION[ $args[0] ]; |
|
| 204 | + if (isset($_SESSION[$args[0]])) { |
|
| 205 | + return $_SESSION[$args[0]]; |
|
| 206 | 206 | } |
| 207 | 207 | |
| 208 | 208 | return null; |
@@ -243,7 +243,7 @@ discard block |
||
| 243 | 243 | $args = func_get_args(); |
| 244 | 244 | |
| 245 | 245 | if (count($args)) { |
| 246 | - if(services()->has('view')) { |
|
| 246 | + if (services()->has('view')) { |
|
| 247 | 247 | $view = services('view'); |
| 248 | 248 | |
| 249 | 249 | return call_user_func_array([&$view, 'load'], $args); |
@@ -37,9 +37,9 @@ |
||
| 37 | 37 | public function __construct() |
| 38 | 38 | { |
| 39 | 39 | if ($config = config()->loadFile('database', true)) { |
| 40 | - if ( ! empty($config[ 'default' ][ 'hostname' ]) AND ! empty($config[ 'default' ][ 'username' ])) { |
|
| 40 | + if ( ! empty($config['default']['hostname']) AND ! empty($config['default']['username'])) { |
|
| 41 | 41 | |
| 42 | - if(profiler() !== false) { |
|
| 42 | + if (profiler() !== false) { |
|
| 43 | 43 | profiler()->watch('Starting Database Service'); |
| 44 | 44 | } |
| 45 | 45 | |
@@ -98,7 +98,7 @@ discard block |
||
| 98 | 98 | */ |
| 99 | 99 | public function push($module) |
| 100 | 100 | { |
| 101 | - if (!in_array($module->getNamespace(), ['O2System\Kernel\\', 'O2System\Framework\\', 'App\\'])) { |
|
| 101 | + if ( ! in_array($module->getNamespace(), ['O2System\Kernel\\', 'O2System\Framework\\', 'App\\'])) { |
|
| 102 | 102 | $this->autoload($module); |
| 103 | 103 | |
| 104 | 104 | parent::push($module); |
@@ -114,7 +114,7 @@ discard block |
||
| 114 | 114 | |
| 115 | 115 | $this->autoloadHelpers($module); |
| 116 | 116 | |
| 117 | - if (!in_array($module->getType(), ['KERNEL', 'FRAMEWORK'])) { |
|
| 117 | + if ( ! in_array($module->getType(), ['KERNEL', 'FRAMEWORK'])) { |
|
| 118 | 118 | // Add Public Dir |
| 119 | 119 | loader()->addPublicDir($module->getPublicDir()); |
| 120 | 120 | |
@@ -359,7 +359,7 @@ discard block |
||
| 359 | 359 | */ |
| 360 | 360 | public function loadRegistry() |
| 361 | 361 | { |
| 362 | - if(empty($this->registry)) { |
|
| 362 | + if (empty($this->registry)) { |
|
| 363 | 363 | $cacheItemPool = cache()->getItemPool('default'); |
| 364 | 364 | |
| 365 | 365 | if (cache()->hasItemPool('registry')) { |
@@ -434,7 +434,7 @@ discard block |
||
| 434 | 434 | ->setIndent(2) |
| 435 | 435 | ->setNewLinesAfter(1) |
| 436 | 436 | ); |
| 437 | - } elseif (!is_array($packageJsonMetadata)) { |
|
| 437 | + } elseif ( ! is_array($packageJsonMetadata)) { |
|
| 438 | 438 | continue; |
| 439 | 439 | } |
| 440 | 440 | |
@@ -464,7 +464,7 @@ discard block |
||
| 464 | 464 | ) |
| 465 | 465 | ); |
| 466 | 466 | |
| 467 | - $moduleSegments = array_map(function ($string) { |
|
| 467 | + $moduleSegments = array_map(function($string) { |
|
| 468 | 468 | return dash(snakecase($string)); |
| 469 | 469 | }, $moduleSegments); |
| 470 | 470 | |
@@ -542,7 +542,7 @@ discard block |
||
| 542 | 542 | { |
| 543 | 543 | $pluralTypes = plural(strtolower($type)); |
| 544 | 544 | |
| 545 | - if (!in_array($pluralTypes, $this->types)) { |
|
| 545 | + if ( ! in_array($pluralTypes, $this->types)) { |
|
| 546 | 546 | array_push($this->types, $pluralTypes); |
| 547 | 547 | } |
| 548 | 548 | |
@@ -686,7 +686,7 @@ discard block |
||
| 686 | 686 | { |
| 687 | 687 | $segments = is_array($segments) ? implode('/', $segments) : $segments; |
| 688 | 688 | |
| 689 | - if(is_string($segments)) { |
|
| 689 | + if (is_string($segments)) { |
|
| 690 | 690 | return (bool)array_key_exists($segments, $this->registry); |
| 691 | 691 | } |
| 692 | 692 | |
@@ -38,7 +38,7 @@ discard block |
||
| 38 | 38 | |
| 39 | 39 | public function optionName($name) |
| 40 | 40 | { |
| 41 | - if(empty($this->optionPath)) { |
|
| 41 | + if (empty($this->optionPath)) { |
|
| 42 | 42 | $this->optionPath = PATH_RESOURCES . 'themes' . DIRECTORY_SEPARATOR; |
| 43 | 43 | } |
| 44 | 44 | |
@@ -78,18 +78,18 @@ discard block |
||
| 78 | 78 | // Make default structure |
| 79 | 79 | mkdir($themePath . 'assets' . DIRECTORY_SEPARATOR, 0777, true); |
| 80 | 80 | |
| 81 | - foreach(['css','js', 'img', 'fonts', 'media', 'packages'] as $assetsDir) { |
|
| 81 | + foreach (['css', 'js', 'img', 'fonts', 'media', 'packages'] as $assetsDir) { |
|
| 82 | 82 | mkdir($themePath . 'assets' . DIRECTORY_SEPARATOR . $assetsDir . DIRECTORY_SEPARATOR, 0777, true); |
| 83 | 83 | } |
| 84 | 84 | |
| 85 | 85 | mkdir($themePath . 'partials' . DIRECTORY_SEPARATOR, 0777, true); |
| 86 | 86 | |
| 87 | - $jsProps[ 'name' ] = readable( |
|
| 87 | + $jsProps['name'] = readable( |
|
| 88 | 88 | $this->optionName, |
| 89 | 89 | true |
| 90 | 90 | ); |
| 91 | 91 | |
| 92 | - $jsProps[ 'created' ] = date('d M Y'); |
|
| 92 | + $jsProps['created'] = date('d M Y'); |
|
| 93 | 93 | |
| 94 | 94 | file_put_contents($themePath . 'theme.jsprop', json_encode($jsProps, JSON_PRETTY_PRINT)); |
| 95 | 95 | |
@@ -110,7 +110,7 @@ discard block |
||
| 110 | 110 | </html> |
| 111 | 111 | THEME; |
| 112 | 112 | |
| 113 | - file_put_contents($themePath . 'theme.phtml', str_replace('@','$',$themeTemplate)); |
|
| 113 | + file_put_contents($themePath . 'theme.phtml', str_replace('@', '$', $themeTemplate)); |
|
| 114 | 114 | |
| 115 | 115 | if (is_dir($themePath)) { |
| 116 | 116 | output()->write( |
@@ -62,7 +62,7 @@ discard block |
||
| 62 | 62 | $properties = json_decode(file_get_contents($propFilePath), true); |
| 63 | 63 | |
| 64 | 64 | if (json_last_error() === JSON_ERROR_NONE) { |
| 65 | - if(isset($properties['config'])) { |
|
| 65 | + if (isset($properties['config'])) { |
|
| 66 | 66 | $this->presets = $properties['presets']; |
| 67 | 67 | unset($properties['presets']); |
| 68 | 68 | } |
@@ -157,10 +157,10 @@ discard block |
||
| 157 | 157 | { |
| 158 | 158 | $extensions = ['.php', '.phtml', '.html', '.tpl']; |
| 159 | 159 | |
| 160 | - if (isset($this->presets[ 'extensions' ])) { |
|
| 161 | - array_unshift($partialsExtensions, $this->presets[ 'extension' ]); |
|
| 162 | - } elseif (isset($this->presets[ 'extension' ])) { |
|
| 163 | - array_unshift($extensions, $this->presets[ 'extension' ]); |
|
| 160 | + if (isset($this->presets['extensions'])) { |
|
| 161 | + array_unshift($partialsExtensions, $this->presets['extension']); |
|
| 162 | + } elseif (isset($this->presets['extension'])) { |
|
| 163 | + array_unshift($extensions, $this->presets['extension']); |
|
| 164 | 164 | } |
| 165 | 165 | |
| 166 | 166 | foreach ($extensions as $extension) { |
@@ -359,12 +359,12 @@ |
||
| 359 | 359 | $session->set('language', language()->getDefault()); |
| 360 | 360 | } |
| 361 | 361 | |
| 362 | - if (config('security')->protection[ 'csrf' ] === true) { |
|
| 362 | + if (config('security')->protection['csrf'] === true) { |
|
| 363 | 363 | $csrfProtection = new Security\Protections\Csrf(); |
| 364 | 364 | $this->services->add($csrfProtection, 'csrfProtection'); |
| 365 | 365 | } |
| 366 | 366 | |
| 367 | - if (config('security')->protection[ 'xss' ] === true) { |
|
| 367 | + if (config('security')->protection['xss'] === true) { |
|
| 368 | 368 | $csrfProtection = new Security\Protections\Xss(); |
| 369 | 369 | $this->services->add($xssProtection, 'xssProtection'); |
| 370 | 370 | } |
@@ -141,20 +141,20 @@ discard block |
||
| 141 | 141 | |
| 142 | 142 | if (is_dir($baseDirectory)) { |
| 143 | 143 | // initialize the namespace prefix array |
| 144 | - if (isset($this->namespaceDirs[ $namespace ]) === false) { |
|
| 145 | - $this->namespaceDirs[ $namespace ] = []; |
|
| 144 | + if (isset($this->namespaceDirs[$namespace]) === false) { |
|
| 145 | + $this->namespaceDirs[$namespace] = []; |
|
| 146 | 146 | } |
| 147 | 147 | |
| 148 | 148 | // retain the base directory for the namespace prefix |
| 149 | - if ( ! in_array($baseDirectory, $this->namespaceDirs[ $namespace ])) { |
|
| 149 | + if ( ! in_array($baseDirectory, $this->namespaceDirs[$namespace])) { |
|
| 150 | 150 | if ($prepend) { |
| 151 | - array_unshift($this->namespaceDirs[ $namespace ], $baseDirectory); |
|
| 151 | + array_unshift($this->namespaceDirs[$namespace], $baseDirectory); |
|
| 152 | 152 | } else { |
| 153 | - array_push($this->namespaceDirs[ $namespace ], $baseDirectory); |
|
| 153 | + array_push($this->namespaceDirs[$namespace], $baseDirectory); |
|
| 154 | 154 | } |
| 155 | 155 | } |
| 156 | 156 | |
| 157 | - $this->namespaceDirsMap[ $baseDirectory ] = $namespace; |
|
| 157 | + $this->namespaceDirsMap[$baseDirectory] = $namespace; |
|
| 158 | 158 | |
| 159 | 159 | // Register Namespace Language |
| 160 | 160 | language()->addFilePath($baseDirectory); |
@@ -192,7 +192,7 @@ discard block |
||
| 192 | 192 | |
| 193 | 193 | if (is_dir($publicDir) and ! in_array($publicDir, $this->publicDirs)) { |
| 194 | 194 | if (isset($offset)) { |
| 195 | - $this->publicDirs[ $offset ] = $publicDir; |
|
| 195 | + $this->publicDirs[$offset] = $publicDir; |
|
| 196 | 196 | } else { |
| 197 | 197 | $this->publicDirs[] = $publicDir; |
| 198 | 198 | } |
@@ -217,7 +217,7 @@ discard block |
||
| 217 | 217 | |
| 218 | 218 | if (is_dir($resourcesDir) and ! in_array($resourcesDir, $this->resourcesDirs)) { |
| 219 | 219 | if (isset($offset)) { |
| 220 | - $this->resourcesDirs[ $offset ] = $resourcesDir; |
|
| 220 | + $this->resourcesDirs[$offset] = $resourcesDir; |
|
| 221 | 221 | } else { |
| 222 | 222 | $this->resourcesDirs[] = $resourcesDir; |
| 223 | 223 | } |
@@ -275,7 +275,7 @@ discard block |
||
| 275 | 275 | $dir = rtrim($dir, DIRECTORY_SEPARATOR) . DIRECTORY_SEPARATOR; |
| 276 | 276 | |
| 277 | 277 | if (array_key_exists($dir, $this->namespaceDirsMap)) { |
| 278 | - return $this->namespaceDirsMap[ $dir ]; |
|
| 278 | + return $this->namespaceDirsMap[$dir]; |
|
| 279 | 279 | } |
| 280 | 280 | |
| 281 | 281 | return false; |
@@ -316,7 +316,7 @@ discard block |
||
| 316 | 316 | $namespace = trim($namespace, '\\') . '\\'; |
| 317 | 317 | |
| 318 | 318 | if (array_key_exists($namespace, $this->namespaceDirs)) { |
| 319 | - return $this->namespaceDirs[ $namespace ]; |
|
| 319 | + return $this->namespaceDirs[$namespace]; |
|
| 320 | 320 | } |
| 321 | 321 | |
| 322 | 322 | return false; |
@@ -339,7 +339,7 @@ discard block |
||
| 339 | 339 | } |
| 340 | 340 | |
| 341 | 341 | if ($this->requireFile($helper)) { |
| 342 | - $this->loadedHelpers[ pathinfo($helper, PATHINFO_FILENAME) ][] = $helper; |
|
| 342 | + $this->loadedHelpers[pathinfo($helper, PATHINFO_FILENAME)][] = $helper; |
|
| 343 | 343 | |
| 344 | 344 | return; |
| 345 | 345 | } |
@@ -355,17 +355,17 @@ discard block |
||
| 355 | 355 | } |
| 356 | 356 | |
| 357 | 357 | if ( ! array_key_exists($helper, $this->loadedHelpers)) { |
| 358 | - $this->loadedHelpers[ $helper ] = []; |
|
| 358 | + $this->loadedHelpers[$helper] = []; |
|
| 359 | 359 | } |
| 360 | 360 | |
| 361 | 361 | foreach ($helperDirectories as $helperDirectory) { |
| 362 | 362 | |
| 363 | 363 | $helperFilePath = $helperDirectory . studlycase($helper) . '.php'; |
| 364 | 364 | |
| 365 | - if (in_array($helperFilePath, $this->loadedHelpers[ $helper ])) { |
|
| 365 | + if (in_array($helperFilePath, $this->loadedHelpers[$helper])) { |
|
| 366 | 366 | continue; |
| 367 | 367 | } elseif ($this->requireFile($helperFilePath)) { |
| 368 | - $this->loadedHelpers[ $helper ][] = $helperFilePath; |
|
| 368 | + $this->loadedHelpers[$helper][] = $helperFilePath; |
|
| 369 | 369 | } |
| 370 | 370 | } |
| 371 | 371 | } |
@@ -396,7 +396,7 @@ discard block |
||
| 396 | 396 | if (false !== ($modules = modules()->getRegistry())) { |
| 397 | 397 | foreach ($modules as $module) { |
| 398 | 398 | if ($module instanceof Module) { |
| 399 | - if (empty($this->namespaceDirs[ $module->getNamespace() ])) { |
|
| 399 | + if (empty($this->namespaceDirs[$module->getNamespace()])) { |
|
| 400 | 400 | $this->addNamespace($module->getNamespace(), $module->getRealPath()); |
| 401 | 401 | } |
| 402 | 402 | } |
@@ -458,12 +458,12 @@ discard block |
||
| 458 | 458 | public function loadMappedFile($namespace, $relativeClass) |
| 459 | 459 | { |
| 460 | 460 | // are there any base directories for this namespace prefix? |
| 461 | - if (isset($this->namespaceDirs[ $namespace ]) === false) { |
|
| 461 | + if (isset($this->namespaceDirs[$namespace]) === false) { |
|
| 462 | 462 | return false; |
| 463 | 463 | } |
| 464 | 464 | |
| 465 | 465 | // look through base directories for this namespace prefix |
| 466 | - foreach ($this->namespaceDirs[ $namespace ] as $namespaceDirectory) { |
|
| 466 | + foreach ($this->namespaceDirs[$namespace] as $namespaceDirectory) { |
|
| 467 | 467 | |
| 468 | 468 | // replace the namespace prefix with the base directory, |
| 469 | 469 | // replace namespace separators with directory separators |
@@ -528,9 +528,9 @@ discard block |
||
| 528 | 528 | public function services(array $classes) |
| 529 | 529 | { |
| 530 | 530 | foreach ($classes as $name => $class) { |
| 531 | - if(is_numeric($name)) { |
|
| 531 | + if (is_numeric($name)) { |
|
| 532 | 532 | services()->load($class); |
| 533 | - } elseif(is_string($name)) { |
|
| 533 | + } elseif (is_string($name)) { |
|
| 534 | 534 | services()->load($class, $name); |
| 535 | 535 | } |
| 536 | 536 | } |
@@ -547,7 +547,7 @@ discard block |
||
| 547 | 547 | |
| 548 | 548 | public function models(array $models) |
| 549 | 549 | { |
| 550 | - foreach($models as $model) { |
|
| 550 | + foreach ($models as $model) { |
|
| 551 | 551 | models()->load($model); |
| 552 | 552 | } |
| 553 | 553 | } |
@@ -59,7 +59,7 @@ discard block |
||
| 59 | 59 | */ |
| 60 | 60 | public function loadRegistry() |
| 61 | 61 | { |
| 62 | - if(empty($this->registry)) { |
|
| 62 | + if (empty($this->registry)) { |
|
| 63 | 63 | $cacheItemPool = cache()->getItemPool('default'); |
| 64 | 64 | |
| 65 | 65 | if (cache()->hasItemPool('registry')) { |
@@ -125,7 +125,7 @@ discard block |
||
| 125 | 125 | ); |
| 126 | 126 | } |
| 127 | 127 | |
| 128 | - $registry[ $package->getDirName() ] = $package; |
|
| 128 | + $registry[$package->getDirName()] = $package; |
|
| 129 | 129 | } elseif (is_cli()) { |
| 130 | 130 | output()->verbose( |
| 131 | 131 | (new Format()) |
@@ -155,7 +155,7 @@ discard block |
||
| 155 | 155 | */ |
| 156 | 156 | public function registered($package) |
| 157 | 157 | { |
| 158 | - return isset($this->registry[ $package ]); |
|
| 158 | + return isset($this->registry[$package]); |
|
| 159 | 159 | } |
| 160 | 160 | |
| 161 | 161 | // ------------------------------------------------------------------------ |
@@ -171,7 +171,7 @@ discard block |
||
| 171 | 171 | { |
| 172 | 172 | if (isset($package)) { |
| 173 | 173 | if ($this->registered($package)) { |
| 174 | - return $this->registry[ $package ]; |
|
| 174 | + return $this->registry[$package]; |
|
| 175 | 175 | } |
| 176 | 176 | |
| 177 | 177 | return false; |
@@ -182,7 +182,7 @@ discard block |
||
| 182 | 182 | |
| 183 | 183 | public function getDefaultMetadata() |
| 184 | 184 | { |
| 185 | - return $this->getRegistry( $this->getDefault() ); |
|
| 185 | + return $this->getRegistry($this->getDefault()); |
|
| 186 | 186 | } |
| 187 | 187 | |
| 188 | 188 | // ------------------------------------------------------------------------ |
@@ -39,7 +39,7 @@ discard block |
||
| 39 | 39 | } |
| 40 | 40 | |
| 41 | 41 | $first = reset($this->storage); |
| 42 | - if ( ! isset($first[ $this->primaryKey ])) { |
|
| 42 | + if ( ! isset($first[$this->primaryKey])) { |
|
| 43 | 43 | $keys = $first->getKeys(); |
| 44 | 44 | $this->primaryKey = reset($keys); |
| 45 | 45 | } |
@@ -48,7 +48,7 @@ discard block |
||
| 48 | 48 | |
| 49 | 49 | public function get($property) |
| 50 | 50 | { |
| 51 | - if (empty($get[ $property ])) { |
|
| 51 | + if (empty($get[$property])) { |
|
| 52 | 52 | if (services()->has($property)) { |
| 53 | 53 | return services()->get($property); |
| 54 | 54 | } elseif (array_key_exists($property, $this->validSubModels)) { |
@@ -63,7 +63,7 @@ discard block |
||
| 63 | 63 | |
| 64 | 64 | final protected function loadSubModel($model) |
| 65 | 65 | { |
| 66 | - if (is_file($this->validSubModels[ $model ])) { |
|
| 66 | + if (is_file($this->validSubModels[$model])) { |
|
| 67 | 67 | $className = '\\' . get_called_class() . '\\' . ucfirst($model); |
| 68 | 68 | $className = str_replace('\Base\\Model', '\Models', $className); |
| 69 | 69 | |