@@ -20,7 +20,7 @@ discard block |
||
| 20 | 20 | { |
| 21 | 21 | $defaultView = self::module()::view(); |
| 22 | 22 | |
| 23 | - $viewClass = is_a(static::class, ModuleView::class, true)? static::class: $defaultView; |
|
| 23 | + $viewClass = is_a(static::class, ModuleView::class, true) ? static::class : $defaultView; |
|
| 24 | 24 | |
| 25 | 25 | $viewAlias = null; |
| 26 | 26 | if ($viewClass !== $defaultView) { |
@@ -44,7 +44,7 @@ discard block |
||
| 44 | 44 | */ |
| 45 | 45 | final public static function moduleLink($module, $method = 'body', $args = []) |
| 46 | 46 | { |
| 47 | - $alias = class_exists($module)? $module::alias(): $module; |
|
| 47 | + $alias = class_exists($module) ? $module::alias() : $module; |
|
| 48 | 48 | |
| 49 | 49 | return url(implode('/', ['view', $alias, $method, self::encodeArgs($args)])); |
| 50 | 50 | } |
@@ -58,13 +58,13 @@ discard block |
||
| 58 | 58 | * @throws \Illuminate\Http\Exceptions\HttpResponseException |
| 59 | 59 | */ |
| 60 | 60 | final public static function decodeArgs($hash) { |
| 61 | - if (! $hash) return []; |
|
| 61 | + if (!$hash) return []; |
|
| 62 | 62 | |
| 63 | 63 | $args = session($hash); |
| 64 | 64 | |
| 65 | 65 | if (is_null($args)) abort(419); |
| 66 | 66 | |
| 67 | - return is_array($args)? $args: [$args]; |
|
| 67 | + return is_array($args) ? $args : [$args]; |
|
| 68 | 68 | } |
| 69 | 69 | |
| 70 | 70 | /** |
@@ -74,9 +74,9 @@ discard block |
||
| 74 | 74 | * @return string |
| 75 | 75 | */ |
| 76 | 76 | final public static function encodeArgs($args) { |
| 77 | - $args = is_array($args)? $args: [$args]; |
|
| 77 | + $args = is_array($args) ? $args : [$args]; |
|
| 78 | 78 | |
| 79 | - if (! $args) return; |
|
| 79 | + if (!$args) return; |
|
| 80 | 80 | |
| 81 | 81 | $hash = md5(serialize($args)); |
| 82 | 82 | |
@@ -58,11 +58,15 @@ discard block |
||
| 58 | 58 | * @throws \Illuminate\Http\Exceptions\HttpResponseException |
| 59 | 59 | */ |
| 60 | 60 | final public static function decodeArgs($hash) { |
| 61 | - if (! $hash) return []; |
|
| 61 | + if (! $hash) { |
|
| 62 | + return []; |
|
| 63 | + } |
|
| 62 | 64 | |
| 63 | 65 | $args = session($hash); |
| 64 | 66 | |
| 65 | - if (is_null($args)) abort(419); |
|
| 67 | + if (is_null($args)) { |
|
| 68 | + abort(419); |
|
| 69 | + } |
|
| 66 | 70 | |
| 67 | 71 | return is_array($args)? $args: [$args]; |
| 68 | 72 | } |
@@ -76,7 +80,9 @@ discard block |
||
| 76 | 80 | final public static function encodeArgs($args) { |
| 77 | 81 | $args = is_array($args)? $args: [$args]; |
| 78 | 82 | |
| 79 | - if (! $args) return; |
|
| 83 | + if (! $args) { |
|
| 84 | + return; |
|
| 85 | + } |
|
| 80 | 86 | |
| 81 | 87 | $hash = md5(serialize($args)); |
| 82 | 88 | |
@@ -20,7 +20,7 @@ discard block |
||
| 20 | 20 | |
| 21 | 21 | public static function isInstalled($classOrAlias) |
| 22 | 22 | { |
| 23 | - return self::getClass($classOrAlias, true)? 1: 0; |
|
| 23 | + return self::getClass($classOrAlias, true) ? 1 : 0; |
|
| 24 | 24 | } |
| 25 | 25 | |
| 26 | 26 | public static function isAvailable($classOrAlias) |
@@ -35,7 +35,7 @@ discard block |
||
| 35 | 35 | * @return string; |
| 36 | 36 | */ |
| 37 | 37 | public static function getClass($classOrAlias, $installedOnly = false) { |
| 38 | - $modules = $installedOnly? self::getInstalled(): self::getAll(); |
|
| 38 | + $modules = $installedOnly ? self::getInstalled() : self::getAll(); |
|
| 39 | 39 | |
| 40 | 40 | if (collect($modules)->contains($classOrAlias)) return $classOrAlias; |
| 41 | 41 | |
@@ -67,9 +67,9 @@ discard block |
||
| 67 | 67 | */ |
| 68 | 68 | public static function getAll() |
| 69 | 69 | { |
| 70 | - return self::getCached('epesi-modules-available', function () { |
|
| 70 | + return self::getCached('epesi-modules-available', function() { |
|
| 71 | 71 | $modules = collect(); |
| 72 | - foreach (array_merge(config('epesi.modules', []), self::packageManifest()->modules()?: []) as $namespace => $path) { |
|
| 72 | + foreach (array_merge(config('epesi.modules', []), self::packageManifest()->modules() ?: []) as $namespace => $path) { |
|
| 73 | 73 | foreach (self::discoverModuleClasses($namespace, $path) as $moduleClass) { |
| 74 | 74 | $modules->add(['alias' => $moduleClass::alias(), 'class' => $moduleClass]); |
| 75 | 75 | } |
@@ -82,7 +82,7 @@ discard block |
||
| 82 | 82 | protected static function discoverModuleClasses($namespace, $basePath) |
| 83 | 83 | { |
| 84 | 84 | $ret = collect(); |
| 85 | - foreach (glob($basePath . '/*', GLOB_ONLYDIR|GLOB_NOSORT) as $path) { |
|
| 85 | + foreach (glob($basePath . '/*', GLOB_ONLYDIR | GLOB_NOSORT) as $path) { |
|
| 86 | 86 | $moduleNamespace = trim($namespace, '\\'); |
| 87 | 87 | |
| 88 | 88 | $subModuleNamespace = $moduleNamespace . '\\' . basename($path); |
@@ -91,11 +91,11 @@ discard block |
||
| 91 | 91 | |
| 92 | 92 | $names = array_slice(explode('\\', $moduleNamespace), -1); |
| 93 | 93 | |
| 94 | - if (! $name = $names? reset($names): '') continue; |
|
| 94 | + if (!$name = $names ? reset($names) : '') continue; |
|
| 95 | 95 | |
| 96 | 96 | $moduleClass = $moduleNamespace . '\\' . $name . 'Core'; |
| 97 | 97 | |
| 98 | - if (! is_a($moduleClass, ModuleCore::class, true)) continue; |
|
| 98 | + if (!is_a($moduleClass, ModuleCore::class, true)) continue; |
|
| 99 | 99 | |
| 100 | 100 | $ret->add($moduleClass); |
| 101 | 101 | } |
@@ -112,7 +112,7 @@ discard block |
||
| 112 | 112 | */ |
| 113 | 113 | protected static function getCached($key, \Closure $default) |
| 114 | 114 | { |
| 115 | - if (! Cache::has($key)) { |
|
| 115 | + if (!Cache::has($key)) { |
|
| 116 | 116 | Cache::forever($key, $default()); |
| 117 | 117 | } |
| 118 | 118 | |
@@ -150,12 +150,12 @@ discard block |
||
| 150 | 150 | */ |
| 151 | 151 | public static function collect($method, $args = []) |
| 152 | 152 | { |
| 153 | - $args = is_array($args)? $args: [$args]; |
|
| 153 | + $args = is_array($args) ? $args : [$args]; |
|
| 154 | 154 | |
| 155 | 155 | $installedModules = self::getInstalled(); |
| 156 | 156 | |
| 157 | 157 | // if epesi is not installed fake having the system module to enable its functionality |
| 158 | - if (! $installedModules->contains(\Epesi\Core\System\SystemCore::class)) { |
|
| 158 | + if (!$installedModules->contains(\Epesi\Core\System\SystemCore::class)) { |
|
| 159 | 159 | $installedModules = collect([ |
| 160 | 160 | 'system' => \Epesi\Core\System\SystemCore::class |
| 161 | 161 | ]); |
@@ -163,9 +163,9 @@ discard block |
||
| 163 | 163 | |
| 164 | 164 | $ret = []; |
| 165 | 165 | foreach ($installedModules as $module) { |
| 166 | - if (! $list = $module::$method(...$args)) continue; |
|
| 166 | + if (!$list = $module::$method(...$args)) continue; |
|
| 167 | 167 | |
| 168 | - $ret = array_merge($ret, is_array($list)? $list: [$list]); |
|
| 168 | + $ret = array_merge($ret, is_array($list) ? $list : [$list]); |
|
| 169 | 169 | } |
| 170 | 170 | |
| 171 | 171 | return $ret; |
@@ -184,7 +184,7 @@ discard block |
||
| 184 | 184 | return true; |
| 185 | 185 | } |
| 186 | 186 | |
| 187 | - if (! $moduleClass = self::getClass($classOrAlias)) { |
|
| 187 | + if (!$moduleClass = self::getClass($classOrAlias)) { |
|
| 188 | 188 | throw new \Exception('Module "' . $classOrAlias . '" could not be identified'); |
| 189 | 189 | } |
| 190 | 190 | |
@@ -214,7 +214,7 @@ discard block |
||
| 214 | 214 | ]); |
| 215 | 215 | |
| 216 | 216 | if ($installRecommended) { |
| 217 | - $installRecommended = is_array($installRecommended)? $installRecommended: $module->recommended(); |
|
| 217 | + $installRecommended = is_array($installRecommended) ? $installRecommended : $module->recommended(); |
|
| 218 | 218 | |
| 219 | 219 | foreach ($installRecommended as $recommendedModule) { |
| 220 | 220 | try { |
@@ -247,10 +247,10 @@ discard block |
||
| 247 | 247 | $parentModule = array_shift($unsatisfiedDependencies); |
| 248 | 248 | |
| 249 | 249 | if (self::$processing[$parentModule]?? false) { |
| 250 | - throw new Exception('Cross dependency: '. $parentModule); |
|
| 250 | + throw new Exception('Cross dependency: ' . $parentModule); |
|
| 251 | 251 | } |
| 252 | 252 | |
| 253 | - if (! self::isAvailable($parentModule)) { |
|
| 253 | + if (!self::isAvailable($parentModule)) { |
|
| 254 | 254 | throw new Exception('Module not found: "' . $parentModule . '"'); |
| 255 | 255 | } |
| 256 | 256 | |
@@ -303,13 +303,13 @@ discard block |
||
| 303 | 303 | |
| 304 | 304 | public static function uninstall($classOrAlias) |
| 305 | 305 | { |
| 306 | - if (! self::isInstalled($classOrAlias)) { |
|
| 306 | + if (!self::isInstalled($classOrAlias)) { |
|
| 307 | 307 | print ('Module "' . $classOrAlias . '" is not installed!'); |
| 308 | 308 | |
| 309 | 309 | return true; |
| 310 | 310 | } |
| 311 | 311 | |
| 312 | - if (! $moduleClass = self::getClass($classOrAlias)) { |
|
| 312 | + if (!$moduleClass = self::getClass($classOrAlias)) { |
|
| 313 | 313 | throw new \Exception('Module "' . $classOrAlias . '" could not be identified'); |
| 314 | 314 | } |
| 315 | 315 | |
@@ -37,7 +37,9 @@ discard block |
||
| 37 | 37 | public static function getClass($classOrAlias, $installedOnly = false) { |
| 38 | 38 | $modules = $installedOnly? self::getInstalled(): self::getAll(); |
| 39 | 39 | |
| 40 | - if (collect($modules)->contains($classOrAlias)) return $classOrAlias; |
|
| 40 | + if (collect($modules)->contains($classOrAlias)) { |
|
| 41 | + return $classOrAlias; |
|
| 42 | + } |
|
| 41 | 43 | |
| 42 | 44 | return $modules[$classOrAlias]?? null; |
| 43 | 45 | } |
@@ -91,11 +93,15 @@ discard block |
||
| 91 | 93 | |
| 92 | 94 | $names = array_slice(explode('\\', $moduleNamespace), -1); |
| 93 | 95 | |
| 94 | - if (! $name = $names? reset($names): '') continue; |
|
| 96 | + if (! $name = $names? reset($names): '') { |
|
| 97 | + continue; |
|
| 98 | + } |
|
| 95 | 99 | |
| 96 | 100 | $moduleClass = $moduleNamespace . '\\' . $name . 'Core'; |
| 97 | 101 | |
| 98 | - if (! is_a($moduleClass, ModuleCore::class, true)) continue; |
|
| 102 | + if (! is_a($moduleClass, ModuleCore::class, true)) { |
|
| 103 | + continue; |
|
| 104 | + } |
|
| 99 | 105 | |
| 100 | 106 | $ret->add($moduleClass); |
| 101 | 107 | } |
@@ -163,7 +169,9 @@ discard block |
||
| 163 | 169 | |
| 164 | 170 | $ret = []; |
| 165 | 171 | foreach ($installedModules as $module) { |
| 166 | - if (! $list = $module::$method(...$args)) continue; |
|
| 172 | + if (! $list = $module::$method(...$args)) { |
|
| 173 | + continue; |
|
| 174 | + } |
|
| 167 | 175 | |
| 168 | 176 | $ret = array_merge($ret, is_array($list)? $list: [$list]); |
| 169 | 177 | } |