@@ -43,13 +43,13 @@ discard block |
||
| 43 | 43 | * @param $urlRoute |
| 44 | 44 | * @return int|string |
| 45 | 45 | */ |
| 46 | - public static function checkArrayEqual($patterns,$urlRoute) |
|
| 46 | + public static function checkArrayEqual($patterns, $urlRoute) |
|
| 47 | 47 | {
|
| 48 | 48 | // calculates the equality difference between |
| 49 | 49 | // the route pattern and the urlRoute value. |
| 50 | - foreach ($patterns as $key=>$pattern){
|
|
| 50 | + foreach ($patterns as $key=>$pattern) {
|
|
| 51 | 51 | |
| 52 | - if(Utils::isArrayEqual($pattern,$urlRoute)){
|
|
| 52 | + if (Utils::isArrayEqual($pattern, $urlRoute)) {
|
|
| 53 | 53 | return $key; |
| 54 | 54 | } |
| 55 | 55 | } |
@@ -68,7 +68,7 @@ discard block |
||
| 68 | 68 | {
|
| 69 | 69 | $route = self::getRouteResolve(); |
| 70 | 70 | |
| 71 | - if(isset($route['class'])){
|
|
| 71 | + if (isset($route['class'])) {
|
|
| 72 | 72 | return $route['class']; |
| 73 | 73 | } |
| 74 | 74 | |
@@ -84,7 +84,7 @@ discard block |
||
| 84 | 84 | {
|
| 85 | 85 | $route = self::getRouteResolve(); |
| 86 | 86 | |
| 87 | - if(isset($route['method'])){
|
|
| 87 | + if (isset($route['method'])) {
|
|
| 88 | 88 | return $route['method']; |
| 89 | 89 | } |
| 90 | 90 | |
@@ -100,7 +100,7 @@ discard block |
||
| 100 | 100 | {
|
| 101 | 101 | $route = self::getRouteResolve(); |
| 102 | 102 | |
| 103 | - if(isset($route['controller'],$route['namespace'])){
|
|
| 103 | + if (isset($route['controller'], $route['namespace'])) {
|
|
| 104 | 104 | return $route['controller'].'/'.$route['namespace']; |
| 105 | 105 | } |
| 106 | 106 | |
@@ -117,17 +117,17 @@ discard block |
||
| 117 | 117 | // get routes data and the resolving pattern |
| 118 | 118 | // Both are interrelated. |
| 119 | 119 | $routes = self::getRoutes(); |
| 120 | - $patternResolve = app()->resolve(RouteMatching::class,['route'=>new self()])->getPatternResolve(); |
|
| 120 | + $patternResolve = app()->resolve(RouteMatching::class, ['route'=>new self()])->getPatternResolve(); |
|
| 121 | 121 | |
| 122 | 122 | // we set the route variables for the route assistant. |
| 123 | 123 | self::updateRouteParameters($patternResolve); |
| 124 | 124 | |
| 125 | 125 | //if routes data is available in pattern resolve. |
| 126 | - if(isset($routes['data'][$patternResolve])){
|
|
| 126 | + if (isset($routes['data'][$patternResolve])) {
|
|
| 127 | 127 | |
| 128 | 128 | // if the incoming http value is |
| 129 | 129 | // the same as the real request method, the data is processed. |
| 130 | - if($routes['data'][$patternResolve]['http'] == strtolower(httpMethod)){
|
|
| 130 | + if ($routes['data'][$patternResolve]['http']==strtolower(httpMethod)) {
|
|
| 131 | 131 | |
| 132 | 132 | // we are set the solved pattern to a variable. |
| 133 | 133 | $resolve = $routes['data'][$patternResolve]; |
@@ -154,22 +154,22 @@ discard block |
||
| 154 | 154 | {
|
| 155 | 155 | $list = []; |
| 156 | 156 | |
| 157 | - if(isset(static::$routes['pattern'][$patternResolvedKey])){
|
|
| 157 | + if (isset(static::$routes['pattern'][$patternResolvedKey])) {
|
|
| 158 | 158 | |
| 159 | 159 | $routeParameters = static::$routes['pattern'][$patternResolvedKey]; |
| 160 | 160 | $route = route(); |
| 161 | 161 | |
| 162 | - foreach($routeParameters as $key=>$param){
|
|
| 162 | + foreach ($routeParameters as $key=>$param) {
|
|
| 163 | 163 | |
| 164 | - $param = Str::replaceWordArray(['{','}','?'],'',$param);
|
|
| 164 | + $param = Str::replaceWordArray(['{', '}', '?'], '', $param);
|
|
| 165 | 165 | |
| 166 | - if(isset($route[$key])){
|
|
| 166 | + if (isset($route[$key])) {
|
|
| 167 | 167 | $list[$param] = $route[$key]; |
| 168 | 168 | } |
| 169 | 169 | } |
| 170 | 170 | } |
| 171 | 171 | |
| 172 | - app()->register('routeParams',$list);
|
|
| 172 | + app()->register('routeParams', $list);
|
|
| 173 | 173 | } |
| 174 | 174 | |
| 175 | 175 | /** |
@@ -181,7 +181,7 @@ discard block |
||
| 181 | 181 | {
|
| 182 | 182 | // we will record the path data for the route. |
| 183 | 183 | // We set the routeMapper variables and the route path. |
| 184 | - self::setPath(function(){
|
|
| 184 | + self::setPath(function() {
|
|
| 185 | 185 | |
| 186 | 186 | // we are sending |
| 187 | 187 | // the controller and routes.php path. |
@@ -193,7 +193,7 @@ discard block |
||
| 193 | 193 | |
| 194 | 194 | // in the paths data, |
| 195 | 195 | // we run the route mapper values and the route files one by one. |
| 196 | - foreach (self::$paths as $mapper=>$controller){
|
|
| 196 | + foreach (self::$paths as $mapper=>$controller) {
|
|
| 197 | 197 | core()->fileSystem->callFile($mapper); |
| 198 | 198 | } |
| 199 | 199 | } |
@@ -207,7 +207,7 @@ discard block |
||
| 207 | 207 | {
|
| 208 | 208 | $routeDefinitor = call_user_func($callback); |
| 209 | 209 | |
| 210 | - if(isset($routeDefinitor['controllerPath']) && isset($routeDefinitor['routePath'])){
|
|
| 210 | + if (isset($routeDefinitor['controllerPath']) && isset($routeDefinitor['routePath'])) {
|
|
| 211 | 211 | |
| 212 | 212 | //the route paths to be saved to the mappers static property. |
| 213 | 213 | static::$mappers['routePaths'][] = $routeDefinitor['routePath']; |
@@ -215,22 +215,22 @@ discard block |
||
| 215 | 215 | |
| 216 | 216 | // if there is endpoint, |
| 217 | 217 | // then only that endpoint is transferred into the path |
| 218 | - if(defined('endpoint')){
|
|
| 218 | + if (defined('endpoint')) {
|
|
| 219 | 219 | |
| 220 | 220 | $routeName = endpoint.'Route.php'; |
| 221 | 221 | $routeMapper = $routeDefinitor['routePath'].''.DIRECTORY_SEPARATOR.''.$routeName; |
| 222 | 222 | |
| 223 | - if(file_exists($routeMapper) && !isset(static::$paths[$routeMapper])){
|
|
| 223 | + if (file_exists($routeMapper) && !isset(static::$paths[$routeMapper])) {
|
|
| 224 | 224 | static::$paths[$routeMapper] = $routeDefinitor['controllerPath']; |
| 225 | 225 | } |
| 226 | 226 | } |
| 227 | - else{
|
|
| 227 | + else {
|
|
| 228 | 228 | |
| 229 | 229 | // if there is no endpoint, |
| 230 | 230 | // all files in the path of the route are transferred to path. |
| 231 | 231 | $allFilesInThatRoutePath = Utils::glob($routeDefinitor['routePath']); |
| 232 | 232 | |
| 233 | - foreach ($allFilesInThatRoutePath as $item){
|
|
| 233 | + foreach ($allFilesInThatRoutePath as $item) {
|
|
| 234 | 234 | static::$paths[$item] = $routeDefinitor['controllerPath']; |
| 235 | 235 | } |
| 236 | 236 | } |
@@ -244,13 +244,13 @@ discard block |
||
| 244 | 244 | * @param $function |
| 245 | 245 | * @param null $controller |
| 246 | 246 | */ |
| 247 | - public static function setRoute($params,$function,$controller=null) |
|
| 247 | + public static function setRoute($params, $function, $controller = null) |
|
| 248 | 248 | {
|
| 249 | - [$pattern,$route] = $params; |
|
| 250 | - [$class,$method] = explode("@",$route);
|
|
| 249 | + [$pattern, $route] = $params; |
|
| 250 | + [$class, $method] = explode("@", $route);
|
|
| 251 | 251 | |
| 252 | 252 | $patternList = array_values( |
| 253 | - array_filter(explode("/",$pattern),'strlen')
|
|
| 253 | + array_filter(explode("/", $pattern), 'strlen')
|
|
| 254 | 254 | ); |
| 255 | 255 | |
| 256 | 256 | static::$routes['pattern'][] = $patternList; |
@@ -260,7 +260,7 @@ discard block |
||
| 260 | 260 | 'http' => $function, |
| 261 | 261 | 'controller' => $controller, |
| 262 | 262 | 'namespace' => static::$namespace, |
| 263 | - 'endpoint' => strtolower(str_replace(StaticPathList::$controllerBundleName,'',static::$namespace)) |
|
| 263 | + 'endpoint' => strtolower(str_replace(StaticPathList::$controllerBundleName, '', static::$namespace)) |
|
| 264 | 264 | ]; |
| 265 | 265 | } |
| 266 | 266 | |
@@ -270,11 +270,11 @@ discard block |
||
| 270 | 270 | * @param null $value |
| 271 | 271 | * @return bool |
| 272 | 272 | */ |
| 273 | - public static function isMatchVaribleRegexPattern($value=null) |
|
| 273 | + public static function isMatchVaribleRegexPattern($value = null) |
|
| 274 | 274 | {
|
| 275 | 275 | // determines if the variable that can be used |
| 276 | 276 | // in the route file meets the regex rule. |
| 277 | - return (preg_match('@\{(.*?)\}@is',$value)) ? true : false;
|
|
| 277 | + return (preg_match('@\{(.*?)\}@is', $value)) ? true : false;
|
|
| 278 | 278 | } |
| 279 | 279 | |
| 280 | 280 | |
@@ -284,11 +284,11 @@ discard block |
||
| 284 | 284 | * @param null $value |
| 285 | 285 | * @return bool |
| 286 | 286 | */ |
| 287 | - public static function isOptionalVaribleRegexPattern($value=null) |
|
| 287 | + public static function isOptionalVaribleRegexPattern($value = null) |
|
| 288 | 288 | {
|
| 289 | 289 | // determines if the variable that can be used |
| 290 | 290 | // in the route file meets the regex rule. |
| 291 | - return preg_match('@\{[a-z]+\?\}@is',$value) ? true : false;
|
|
| 291 | + return preg_match('@\{[a-z]+\?\}@is', $value) ? true : false;
|
|
| 292 | 292 | } |
| 293 | 293 | |
| 294 | 294 | |
@@ -48,7 +48,7 @@ discard block |
||
| 48 | 48 | */ |
| 49 | 49 | function applicationKey() |
| 50 | 50 | {
|
| 51 | - if(property_exists($kernel=app()->kernel(),'applicationKey')){
|
|
| 51 | + if (property_exists($kernel = app()->kernel(), 'applicationKey')) {
|
|
| 52 | 52 | return $kernel->applicationKey; |
| 53 | 53 | } |
| 54 | 54 | return null; |
@@ -81,7 +81,7 @@ discard block |
||
| 81 | 81 | */ |
| 82 | 82 | function bundleName() |
| 83 | 83 | {
|
| 84 | - if(defined('endpoint')){
|
|
| 84 | + if (defined('endpoint')) {
|
|
| 85 | 85 | |
| 86 | 86 | return endpoint.''.StaticPathList::$controllerBundleName; |
| 87 | 87 | } |
@@ -96,11 +96,11 @@ discard block |
||
| 96 | 96 | * @param null $default |
| 97 | 97 | * @return mixed|null |
| 98 | 98 | */ |
| 99 | - function config($config=null,$default=null) |
|
| 99 | + function config($config = null, $default = null) |
|
| 100 | 100 | {
|
| 101 | 101 | $configResult = app()->config($config); |
| 102 | 102 | |
| 103 | - if($configResult === null && $default!==null){
|
|
| 103 | + if ($configResult===null && $default!==null) {
|
|
| 104 | 104 | return $default; |
| 105 | 105 | } |
| 106 | 106 | |
@@ -115,9 +115,9 @@ discard block |
||
| 115 | 115 | * @param $bind array |
| 116 | 116 | * @return mixed |
| 117 | 117 | */ |
| 118 | - function container($class,$bind=array()) |
|
| 118 | + function container($class, $bind = array()) |
|
| 119 | 119 | {
|
| 120 | - return app()->singleton()->appClass->container(appInstance(),$class,$bind); |
|
| 120 | + return app()->singleton()->appClass->container(appInstance(), $class, $bind); |
|
| 121 | 121 | } |
| 122 | 122 | } |
| 123 | 123 | |
@@ -177,10 +177,10 @@ discard block |
||
| 177 | 177 | * @param array $params |
| 178 | 178 | * @return ExceptionContracts |
| 179 | 179 | */ |
| 180 | - function exception($name=null,$params=array()) |
|
| 180 | + function exception($name = null, $params = array()) |
|
| 181 | 181 | {
|
| 182 | - $exceptionManager=ExceptionManager::class; |
|
| 183 | - return app()->resolve($exceptionManager,['name'=>$name,'params'=>$params]); |
|
| 182 | + $exceptionManager = ExceptionManager::class; |
|
| 183 | + return app()->resolve($exceptionManager, ['name'=>$name, 'params'=>$params]); |
|
| 184 | 184 | } |
| 185 | 185 | } |
| 186 | 186 | |
@@ -190,13 +190,13 @@ discard block |
||
| 190 | 190 | * @param null $locale |
| 191 | 191 | * @return Generator |
| 192 | 192 | */ |
| 193 | - function faker($locale=null) |
|
| 193 | + function faker($locale = null) |
|
| 194 | 194 | {
|
| 195 | - if($locale===null){
|
|
| 196 | - $faker=Factory::create(); |
|
| 195 | + if ($locale===null) {
|
|
| 196 | + $faker = Factory::create(); |
|
| 197 | 197 | } |
| 198 | - else{
|
|
| 199 | - $faker=Factory::create($locale); |
|
| 198 | + else {
|
|
| 199 | + $faker = Factory::create($locale); |
|
| 200 | 200 | } |
| 201 | 201 | |
| 202 | 202 | return $faker; |
@@ -207,8 +207,8 @@ discard block |
||
| 207 | 207 | |
| 208 | 208 | function fingerPrint() |
| 209 | 209 | {
|
| 210 | - return md5(sha1(implode("|",[
|
|
| 211 | - request()->getClientIp(),$_SERVER['HTTP_USER_AGENT'],applicationKey() |
|
| 210 | + return md5(sha1(implode("|", [
|
|
| 211 | + request()->getClientIp(), $_SERVER['HTTP_USER_AGENT'], applicationKey() |
|
| 212 | 212 | ]))); |
| 213 | 213 | } |
| 214 | 214 | } |
@@ -228,10 +228,10 @@ discard block |
||
| 228 | 228 | * @param null $default |
| 229 | 229 | * @return null |
| 230 | 230 | */ |
| 231 | - function get($param=null,$default=null) |
|
| 231 | + function get($param = null, $default = null) |
|
| 232 | 232 | {
|
| 233 | 233 | //symfony request query object |
| 234 | - $get=core()->get; |
|
| 234 | + $get = core()->get; |
|
| 235 | 235 | |
| 236 | 236 | return ($param===null) ? $get : (isset($get[$param]) ? $get[$param] : $default); |
| 237 | 237 | } |
@@ -244,14 +244,14 @@ discard block |
||
| 244 | 244 | * @param null $default |
| 245 | 245 | * @return array |
| 246 | 246 | */ |
| 247 | - function headers($param=null,$default=null) |
|
| 247 | + function headers($param = null, $default = null) |
|
| 248 | 248 | {
|
| 249 | - $list=[]; |
|
| 249 | + $list = []; |
|
| 250 | 250 | |
| 251 | 251 | //We only get the objects in the list name to match the header objects |
| 252 | 252 | //that come with the request path to the objects sent by the client |
| 253 | 253 | foreach (request()->headers->all() as $key=>$value) {
|
| 254 | - $list[$key]=$value; |
|
| 254 | + $list[$key] = $value; |
|
| 255 | 255 | } |
| 256 | 256 | |
| 257 | 257 | //return header list |
@@ -276,9 +276,9 @@ discard block |
||
| 276 | 276 | * @param $file null |
| 277 | 277 | * @return LoggerHandler |
| 278 | 278 | */ |
| 279 | - function logger($file=null) |
|
| 279 | + function logger($file = null) |
|
| 280 | 280 | {
|
| 281 | - return app()->resolve(LoggerHandler::class,['file'=>$file]); |
|
| 281 | + return app()->resolve(LoggerHandler::class, ['file'=>$file]); |
|
| 282 | 282 | } |
| 283 | 283 | } |
| 284 | 284 | |
@@ -300,7 +300,7 @@ discard block |
||
| 300 | 300 | */ |
| 301 | 301 | function response() |
| 302 | 302 | {
|
| 303 | - $object=debug_backtrace()[1]['object']; |
|
| 303 | + $object = debug_backtrace()[1]['object']; |
|
| 304 | 304 | return new ResponseOutManager($object); |
| 305 | 305 | } |
| 306 | 306 | } |
@@ -315,9 +315,9 @@ discard block |
||
| 315 | 315 | * @throws \DI\DependencyException |
| 316 | 316 | * @throws \DI\NotFoundException |
| 317 | 317 | */ |
| 318 | - function resolve($class,$bind=array()) |
|
| 318 | + function resolve($class, $bind = array()) |
|
| 319 | 319 | {
|
| 320 | - return app()->resolve($class,$bind); |
|
| 320 | + return app()->resolve($class, $bind); |
|
| 321 | 321 | } |
| 322 | 322 | } |
| 323 | 323 | |
@@ -328,7 +328,7 @@ discard block |
||
| 328 | 328 | */ |
| 329 | 329 | function policy() |
| 330 | 330 | {
|
| 331 | - $policyPath = implode('/',[
|
|
| 331 | + $policyPath = implode('/', [
|
|
| 332 | 332 | Route::getRouteControllerNamespace(), |
| 333 | 333 | 'Policy', |
| 334 | 334 | Route::getRouteControllerClass().'Policy' |
@@ -336,7 +336,7 @@ discard block |
||
| 336 | 336 | |
| 337 | 337 | $policyNamespace = Utils::getNamespace($policyPath); |
| 338 | 338 | |
| 339 | - if(Utils::isNamespaceExists($policyNamespace)){
|
|
| 339 | + if (Utils::isNamespaceExists($policyNamespace)) {
|
|
| 340 | 340 | return app()->resolve(Utils::getNamespace($policyPath)); |
| 341 | 341 | } |
| 342 | 342 | |
@@ -351,10 +351,10 @@ discard block |
||
| 351 | 351 | * @param $key |
| 352 | 352 | * @return mixed |
| 353 | 353 | */ |
| 354 | - function route($key=null) |
|
| 354 | + function route($key = null) |
|
| 355 | 355 | {
|
| 356 | - if(is_null($key)){
|
|
| 357 | - return array_map(function($route){
|
|
| 356 | + if (is_null($key)) {
|
|
| 357 | + return array_map(function($route) {
|
|
| 358 | 358 | return strtolower($route); |
| 359 | 359 | },app()->singleton()->appClass->route($key)); |
| 360 | 360 | } |
@@ -382,10 +382,10 @@ discard block |
||
| 382 | 382 | * @param null $default |
| 383 | 383 | * @return mixed |
| 384 | 384 | */ |
| 385 | - function post($param=null,$default=null) |
|
| 385 | + function post($param = null, $default = null) |
|
| 386 | 386 | {
|
| 387 | 387 | //symfony request query object |
| 388 | - $post=core()->post; |
|
| 388 | + $post = core()->post; |
|
| 389 | 389 | |
| 390 | 390 | return ($param===null) ? $post : (isset($post[$param]) ? $post[$param] : $default); |
| 391 | 391 | } |
@@ -416,8 +416,8 @@ discard block |
||
| 416 | 416 | * @param array $select |
| 417 | 417 | * @return mixed |
| 418 | 418 | */ |
| 419 | - function trans($lang,$select=array()) |
|
| 419 | + function trans($lang, $select = array()) |
|
| 420 | 420 | {
|
| 421 | - return app()->singleton()->appClass->translator($lang,$select); |
|
| 421 | + return app()->singleton()->appClass->translator($lang, $select); |
|
| 422 | 422 | } |
| 423 | 423 | } |
| 424 | 424 | \ No newline at end of file |