@@ -9,28 +9,28 @@ discard block |
||
| 9 | 9 | * @param $param |
| 10 | 10 | * @return mixed |
| 11 | 11 | */ |
| 12 | - public function resolveContainer($parameter,$param) |
|
| 12 | + public function resolveContainer($parameter, $param) |
|
| 13 | 13 | {
|
| 14 | 14 | //we get the custom name container value via serviceContainer. |
| 15 | - $specialNameContainer=app()->singleton()->serviceContainer[$parameter->getName()]; |
|
| 15 | + $specialNameContainer = app()->singleton()->serviceContainer[$parameter->getName()]; |
|
| 16 | 16 | |
| 17 | 17 | // we determine whether the value of |
| 18 | 18 | // the private name container is class. |
| 19 | - if(class_exists($specialNameContainer)){
|
|
| 19 | + if (class_exists($specialNameContainer)) {
|
|
| 20 | 20 | |
| 21 | 21 | //we resolve the custom name container through the service container. |
| 22 | - $resolveSpecialNameContainer=app()->resolve($specialNameContainer); |
|
| 22 | + $resolveSpecialNameContainer = app()->resolve($specialNameContainer); |
|
| 23 | 23 | |
| 24 | 24 | // we need to find out whether we have |
| 25 | 25 | // the specific name getNameContainer method solved |
| 26 | 26 | // so we can use the special name container value with bind. |
| 27 | - if(method_exists($resolveSpecialNameContainer,'getNameContainer')){
|
|
| 27 | + if (method_exists($resolveSpecialNameContainer, 'getNameContainer')) {
|
|
| 28 | 28 | |
| 29 | 29 | // when we bind the name container method, |
| 30 | 30 | // we check the existence of the default value so that we can use it directly for lean. |
| 31 | 31 | // and then save it in the parameter context by executing the getNameContainer method. |
| 32 | - $getParams=($parameter->isDefaultValueAvailable()) ? $parameter->getDefaultValue() : null; |
|
| 33 | - $param[$parameter->getName()]=$resolveSpecialNameContainer->getNameContainer($getParams); |
|
| 32 | + $getParams = ($parameter->isDefaultValueAvailable()) ? $parameter->getDefaultValue() : null; |
|
| 33 | + $param[$parameter->getName()] = $resolveSpecialNameContainer->getNameContainer($getParams); |
|
| 34 | 34 | |
| 35 | 35 | //return $param |
| 36 | 36 | return $param; |
@@ -38,7 +38,7 @@ discard block |
||
| 38 | 38 | } |
| 39 | 39 | |
| 40 | 40 | //parameter context for special name container and return |
| 41 | - $param[$parameter->getName()]=$parameter->getDefaultValue(); |
|
| 41 | + $param[$parameter->getName()] = $parameter->getDefaultValue(); |
|
| 42 | 42 | return $param; |
| 43 | 43 | } |
| 44 | 44 | |
@@ -66,12 +66,12 @@ |
||
| 66 | 66 | $list = []; |
| 67 | 67 | |
| 68 | 68 | if(preg_match('@route\((.*?)\)\r\n@is',$doc,$route)){
|
| 69 | - $routeParams = explode (" ",$route[1]);
|
|
| 69 | + $routeParams = explode (" ",$route[1]);
|
|
| 70 | 70 | |
| 71 | - foreach ($routeParams as $routeParam){
|
|
| 72 | - $routeParam = explode(":",$routeParam);
|
|
| 73 | - $list[$routeParam[0]] = $routeParam[1]; |
|
| 74 | - } |
|
| 71 | + foreach ($routeParams as $routeParam){
|
|
| 72 | + $routeParam = explode(":",$routeParam);
|
|
| 73 | + $list[$routeParam[0]] = $routeParam[1]; |
|
| 74 | + } |
|
| 75 | 75 | } |
| 76 | 76 | |
| 77 | 77 | return $list; |
@@ -10,7 +10,7 @@ discard block |
||
| 10 | 10 | /** |
| 11 | 11 | * @var array $parameters |
| 12 | 12 | */ |
| 13 | - protected $parameters=array(); |
|
| 13 | + protected $parameters = array(); |
|
| 14 | 14 | |
| 15 | 15 | /** |
| 16 | 16 | * @var $reflection \ReflectionMethod |
@@ -32,12 +32,12 @@ discard block |
||
| 32 | 32 | private function checkRouteObligation($parameters) |
| 33 | 33 | {
|
| 34 | 34 | //check $parameters value for obligation |
| 35 | - foreach ($parameters as $parameterKey=>$parameter){
|
|
| 35 | + foreach ($parameters as $parameterKey=>$parameter) {
|
|
| 36 | 36 | |
| 37 | 37 | // we use a question mark as a constant value which is not a necessity. |
| 38 | 38 | // according to the presence of this sign, |
| 39 | 39 | // we take this mark as a parameter to save the value as a real value. |
| 40 | - $this->parameters[] = Str::replaceArray('?',[''],$parameter);
|
|
| 40 | + $this->parameters[] = Str::replaceArray('?', [''], $parameter);
|
|
| 41 | 41 | |
| 42 | 42 | // we take all the route values |
| 43 | 43 | // into the allRoutes variable. |
@@ -45,11 +45,11 @@ discard block |
||
| 45 | 45 | |
| 46 | 46 | // the values that do not end with the question mark |
| 47 | 47 | // as mandatory values will be required as parameters. |
| 48 | - if(!Str::endsWith($parameter,'?')){
|
|
| 48 | + if (!Str::endsWith($parameter, '?')) {
|
|
| 49 | 49 | |
| 50 | 50 | // if the requirement is not in the true route value, |
| 51 | 51 | // the exception will be thrown with the missing parameter message. |
| 52 | - if(!isset($allRoutes[$parameterKey])){
|
|
| 52 | + if (!isset($allRoutes[$parameterKey])) {
|
|
| 53 | 53 | exception()->invalidArgument('Route parameter is missing [ as '.$parameterKey.' key ]');
|
| 54 | 54 | } |
| 55 | 55 | } |
@@ -65,11 +65,11 @@ discard block |
||
| 65 | 65 | |
| 66 | 66 | $list = []; |
| 67 | 67 | |
| 68 | - if(preg_match('@route\((.*?)\)\r\n@is',$doc,$route)){
|
|
| 69 | - $routeParams = explode (" ",$route[1]);
|
|
| 68 | + if (preg_match('@route\((.*?)\)\r\n@is', $doc, $route)) {
|
|
| 69 | + $routeParams = explode(" ", $route[1]);
|
|
| 70 | 70 | |
| 71 | - foreach ($routeParams as $routeParam){
|
|
| 72 | - $routeParam = explode(":",$routeParam);
|
|
| 71 | + foreach ($routeParams as $routeParam) {
|
|
| 72 | + $routeParam = explode(":", $routeParam);
|
|
| 73 | 73 | $list[$routeParam[0]] = $routeParam[1]; |
| 74 | 74 | } |
| 75 | 75 | } |
@@ -82,7 +82,7 @@ discard block |
||
| 82 | 82 | * @param $param |
| 83 | 83 | * @return mixed |
| 84 | 84 | */ |
| 85 | - public function resolveContainer($parameters,$param) |
|
| 85 | + public function resolveContainer($parameters, $param) |
|
| 86 | 86 | {
|
| 87 | 87 | // we apply this method to obtain reliable |
| 88 | 88 | // route data by checking the route requirement. |
@@ -102,7 +102,7 @@ discard block |
||
| 102 | 102 | // the user will determine |
| 103 | 103 | // if the route parameters are in |
| 104 | 104 | // accordance with the regular expression rule as a pattern. |
| 105 | - $this->routePatternProcess($serviceConf,$param['route']); |
|
| 105 | + $this->routePatternProcess($serviceConf, $param['route']); |
|
| 106 | 106 | |
| 107 | 107 | // when the route nameContainer is defined, |
| 108 | 108 | // these keys must be absolute string data. |
@@ -116,34 +116,34 @@ discard block |
||
| 116 | 116 | * @param $serviceConf |
| 117 | 117 | * @param $params |
| 118 | 118 | */ |
| 119 | - private function routePatternProcess($serviceConf,$params) |
|
| 119 | + private function routePatternProcess($serviceConf, $params) |
|
| 120 | 120 | {
|
| 121 | - if(isset($serviceConf['routeParameters'])){
|
|
| 121 | + if (isset($serviceConf['routeParameters'])) {
|
|
| 122 | 122 | |
| 123 | 123 | $routeParameters = $serviceConf['routeParameters']; |
| 124 | 124 | |
| 125 | 125 | $pattern = []; |
| 126 | 126 | |
| 127 | - if(isset($routeParameters[strtolower(httpMethod)][methodName]['pattern'])){
|
|
| 127 | + if (isset($routeParameters[strtolower(httpMethod)][methodName]['pattern'])) {
|
|
| 128 | 128 | $pattern = $routeParameters[strtolower(httpMethod)][methodName]['pattern']; |
| 129 | 129 | } |
| 130 | 130 | |
| 131 | - foreach ($params as $key=>$param){
|
|
| 131 | + foreach ($params as $key=>$param) {
|
|
| 132 | 132 | |
| 133 | 133 | $routeFromDocComment = $this->getRouteFromDocComment(); |
| 134 | 134 | |
| 135 | - if(isset($routeFromDocComment[$key])){
|
|
| 135 | + if (isset($routeFromDocComment[$key])) {
|
|
| 136 | 136 | |
| 137 | - if(!preg_match('@^'.$routeFromDocComment[$key].'$@is',$param)){
|
|
| 137 | + if (!preg_match('@^'.$routeFromDocComment[$key].'$@is', $param)) {
|
|
| 138 | 138 | exception() |
| 139 | 139 | ->invalidArgument('route '.$key.' value is not valid for configuration as pattern');
|
| 140 | 140 | } |
| 141 | 141 | } |
| 142 | - else{
|
|
| 142 | + else {
|
|
| 143 | 143 | |
| 144 | - if(isset($pattern[$key])){
|
|
| 144 | + if (isset($pattern[$key])) {
|
|
| 145 | 145 | |
| 146 | - if(!preg_match('@'.$pattern[$key].'$@is',$param)){
|
|
| 146 | + if (!preg_match('@'.$pattern[$key].'$@is', $param)) {
|
|
| 147 | 147 | exception() |
| 148 | 148 | ->invalidArgument('route id value is not valid for configuration as pattern');
|
| 149 | 149 | } |
@@ -163,9 +163,9 @@ discard block |
||
| 163 | 163 | {
|
| 164 | 164 | // we pass all the key values of |
| 165 | 165 | // the route data through the string control. |
| 166 | - foreach (route() as $routeKey=>$routeValue){
|
|
| 166 | + foreach (route() as $routeKey=>$routeValue) {
|
|
| 167 | 167 | |
| 168 | - if(in_array($routeKey,$this->parameters) && preg_match('@[^a-z||\?]@',$routeKey)){
|
|
| 168 | + if (in_array($routeKey, $this->parameters) && preg_match('@[^a-z||\?]@', $routeKey)) {
|
|
| 169 | 169 | exception()->invalidArgument('Route key should be only string value');
|
| 170 | 170 | } |
| 171 | 171 | } |
@@ -138,8 +138,7 @@ |
||
| 138 | 138 | exception() |
| 139 | 139 | ->invalidArgument('route '.$key.' value is not valid for configuration as pattern');
|
| 140 | 140 | } |
| 141 | - } |
|
| 142 | - else{
|
|
| 141 | + } else{
|
|
| 143 | 142 | |
| 144 | 143 | if(isset($pattern[$key])){
|
| 145 | 144 | |
@@ -13,23 +13,23 @@ discard block |
||
| 13 | 13 | */ |
| 14 | 14 | public function getColoredString($string, $foreground_color = null, $background_color = null) |
| 15 | 15 | {
|
| 16 | - $this->consoleLogger($string,'info'); |
|
| 16 | + $this->consoleLogger($string, 'info'); |
|
| 17 | 17 | |
| 18 | - if(isset($this->argument['commandCall'])) return $string; |
|
| 18 | + if (isset($this->argument['commandCall'])) return $string; |
|
| 19 | 19 | |
| 20 | 20 | $colored_string = ""; |
| 21 | 21 | |
| 22 | 22 | // Check if given foreground color found |
| 23 | 23 | if (isset($this->foreground_colors[$foreground_color])) {
|
| 24 | - $colored_string .= "\033[" . $this->foreground_colors[$foreground_color] . "m"; |
|
| 24 | + $colored_string .= "\033[".$this->foreground_colors[$foreground_color]."m"; |
|
| 25 | 25 | } |
| 26 | 26 | // Check if given background color found |
| 27 | 27 | if (isset($this->background_colors[$background_color])) {
|
| 28 | - $colored_string .= "\033[" . $this->background_colors[$background_color] . "m"; |
|
| 28 | + $colored_string .= "\033[".$this->background_colors[$background_color]."m"; |
|
| 29 | 29 | } |
| 30 | 30 | |
| 31 | 31 | // Add string and end coloring |
| 32 | - $colored_string .= $string . "\033[0m"; |
|
| 32 | + $colored_string .= $string."\033[0m"; |
|
| 33 | 33 | |
| 34 | 34 | return $colored_string; |
| 35 | 35 | } |
@@ -43,25 +43,25 @@ discard block |
||
| 43 | 43 | */ |
| 44 | 44 | public function info($string, $foreground_color = 'blue', $background_color = 'white') |
| 45 | 45 | {
|
| 46 | - $this->consoleLogger($string,'info'); |
|
| 46 | + $this->consoleLogger($string, 'info'); |
|
| 47 | 47 | |
| 48 | - if(isset($this->argument['commandCall'])) return $string; |
|
| 48 | + if (isset($this->argument['commandCall'])) return $string; |
|
| 49 | 49 | |
| 50 | 50 | $colored_string = ""; |
| 51 | 51 | |
| 52 | 52 | // Check if given foreground color found |
| 53 | 53 | if (isset($this->foreground_colors[$foreground_color])) {
|
| 54 | - $colored_string .= "\033[" . $this->foreground_colors[$foreground_color] . "m"; |
|
| 54 | + $colored_string .= "\033[".$this->foreground_colors[$foreground_color]."m"; |
|
| 55 | 55 | } |
| 56 | 56 | // Check if given background color found |
| 57 | 57 | if (isset($this->background_colors[$background_color])) {
|
| 58 | - $colored_string .= "\033[" . $this->background_colors[$background_color] . "m"; |
|
| 58 | + $colored_string .= "\033[".$this->background_colors[$background_color]."m"; |
|
| 59 | 59 | } |
| 60 | 60 | |
| 61 | 61 | // Add string and end coloring |
| 62 | - $colored_string .= $string . "\033[0m"; |
|
| 62 | + $colored_string .= $string."\033[0m"; |
|
| 63 | 63 | |
| 64 | - return ''.$colored_string.'' . PHP_EOL; |
|
| 64 | + return ''.$colored_string.''.PHP_EOL; |
|
| 65 | 65 | } |
| 66 | 66 | |
| 67 | 67 | /** |
@@ -71,19 +71,19 @@ discard block |
||
| 71 | 71 | */ |
| 72 | 72 | public function red($string, $foreground_color = 'red') |
| 73 | 73 | {
|
| 74 | - $this->consoleLogger($string,'info'); |
|
| 74 | + $this->consoleLogger($string, 'info'); |
|
| 75 | 75 | |
| 76 | - if(isset($this->argument['commandCall'])) return $string; |
|
| 76 | + if (isset($this->argument['commandCall'])) return $string; |
|
| 77 | 77 | |
| 78 | 78 | $colored_string = ""; |
| 79 | 79 | |
| 80 | 80 | // Check if given foreground color found |
| 81 | 81 | if (isset($this->foreground_colors[$foreground_color])) {
|
| 82 | - $colored_string .= "\033[" . $this->foreground_colors[$foreground_color] . "m"; |
|
| 82 | + $colored_string .= "\033[".$this->foreground_colors[$foreground_color]."m"; |
|
| 83 | 83 | } |
| 84 | 84 | |
| 85 | 85 | // Add string and end coloring |
| 86 | - $colored_string .= $string . "\033[0m"; |
|
| 86 | + $colored_string .= $string."\033[0m"; |
|
| 87 | 87 | |
| 88 | 88 | return $colored_string; |
| 89 | 89 | } |
@@ -97,25 +97,25 @@ discard block |
||
| 97 | 97 | */ |
| 98 | 98 | public function success($string, $foreground_color = 'white', $background_color = 'yellow') |
| 99 | 99 | {
|
| 100 | - $this->consoleLogger($string,'info'); |
|
| 100 | + $this->consoleLogger($string, 'info'); |
|
| 101 | 101 | |
| 102 | - if(isset($this->argument['commandCall'])) return $string; |
|
| 102 | + if (isset($this->argument['commandCall'])) return $string; |
|
| 103 | 103 | |
| 104 | 104 | $colored_string = ""; |
| 105 | 105 | |
| 106 | 106 | // Check if given foreground color found |
| 107 | 107 | if (isset($this->foreground_colors[$foreground_color])) {
|
| 108 | - $colored_string .= "\033[" . $this->foreground_colors[$foreground_color] . "m"; |
|
| 108 | + $colored_string .= "\033[".$this->foreground_colors[$foreground_color]."m"; |
|
| 109 | 109 | } |
| 110 | 110 | // Check if given background color found |
| 111 | 111 | if (isset($this->background_colors[$background_color])) {
|
| 112 | - $colored_string .= "\033[" . $this->background_colors[$background_color] . "m"; |
|
| 112 | + $colored_string .= "\033[".$this->background_colors[$background_color]."m"; |
|
| 113 | 113 | } |
| 114 | 114 | |
| 115 | 115 | // Add string and end coloring |
| 116 | - $colored_string .= $string . "\033[0m"; |
|
| 116 | + $colored_string .= $string."\033[0m"; |
|
| 117 | 117 | |
| 118 | - return ''.$colored_string.'' . PHP_EOL; |
|
| 118 | + return ''.$colored_string.''.PHP_EOL; |
|
| 119 | 119 | } |
| 120 | 120 | |
| 121 | 121 | /** |
@@ -126,25 +126,25 @@ discard block |
||
| 126 | 126 | */ |
| 127 | 127 | public function classical($string, $foreground_color = 'red', $background_color = 'white') |
| 128 | 128 | {
|
| 129 | - $this->consoleLogger($string,'info'); |
|
| 129 | + $this->consoleLogger($string, 'info'); |
|
| 130 | 130 | |
| 131 | - if(isset($this->argument['commandCall'])) return $string; |
|
| 131 | + if (isset($this->argument['commandCall'])) return $string; |
|
| 132 | 132 | |
| 133 | 133 | $colored_string = ""; |
| 134 | 134 | |
| 135 | 135 | // Check if given foreground color found |
| 136 | 136 | if (isset($this->foreground_colors[$foreground_color])) {
|
| 137 | - $colored_string .= "\033[" . $this->foreground_colors[$foreground_color] . "m"; |
|
| 137 | + $colored_string .= "\033[".$this->foreground_colors[$foreground_color]."m"; |
|
| 138 | 138 | } |
| 139 | 139 | // Check if given background color found |
| 140 | 140 | if (isset($this->background_colors[$background_color])) {
|
| 141 | - $colored_string .= "\033[" . $this->background_colors[$background_color] . "m"; |
|
| 141 | + $colored_string .= "\033[".$this->background_colors[$background_color]."m"; |
|
| 142 | 142 | } |
| 143 | 143 | |
| 144 | 144 | // Add string and end coloring |
| 145 | - $colored_string .= $string . "\033[0m"; |
|
| 145 | + $colored_string .= $string."\033[0m"; |
|
| 146 | 146 | |
| 147 | - return ''.$colored_string.'' . PHP_EOL; |
|
| 147 | + return ''.$colored_string.''.PHP_EOL; |
|
| 148 | 148 | } |
| 149 | 149 | |
| 150 | 150 | /** |
@@ -155,25 +155,25 @@ discard block |
||
| 155 | 155 | */ |
| 156 | 156 | public function bluePrint($string, $foreground_color = 'blue', $background_color = 'white') |
| 157 | 157 | {
|
| 158 | - $this->consoleLogger($string,'info'); |
|
| 158 | + $this->consoleLogger($string, 'info'); |
|
| 159 | 159 | |
| 160 | - if(isset($this->argument['commandCall'])) return $string; |
|
| 160 | + if (isset($this->argument['commandCall'])) return $string; |
|
| 161 | 161 | |
| 162 | 162 | $colored_string = ""; |
| 163 | 163 | |
| 164 | 164 | // Check if given foreground color found |
| 165 | 165 | if (isset($this->foreground_colors[$foreground_color])) {
|
| 166 | - $colored_string .= "\033[" . $this->foreground_colors[$foreground_color] . "m"; |
|
| 166 | + $colored_string .= "\033[".$this->foreground_colors[$foreground_color]."m"; |
|
| 167 | 167 | } |
| 168 | 168 | // Check if given background color found |
| 169 | 169 | if (isset($this->background_colors[$background_color])) {
|
| 170 | - $colored_string .= "\033[" . $this->background_colors[$background_color] . "m"; |
|
| 170 | + $colored_string .= "\033[".$this->background_colors[$background_color]."m"; |
|
| 171 | 171 | } |
| 172 | 172 | |
| 173 | 173 | // Add string and end coloring |
| 174 | - $colored_string .= $string . "\033[0m"; |
|
| 174 | + $colored_string .= $string."\033[0m"; |
|
| 175 | 175 | |
| 176 | - return ''.$colored_string.'' . PHP_EOL; |
|
| 176 | + return ''.$colored_string.''.PHP_EOL; |
|
| 177 | 177 | } |
| 178 | 178 | |
| 179 | 179 | /** |
@@ -184,25 +184,25 @@ discard block |
||
| 184 | 184 | */ |
| 185 | 185 | public function yellowPrint($string, $foreground_color = 'black', $background_color = 'yellow') |
| 186 | 186 | {
|
| 187 | - $this->consoleLogger($string,'info'); |
|
| 187 | + $this->consoleLogger($string, 'info'); |
|
| 188 | 188 | |
| 189 | - if(isset($this->argument['commandCall'])) return $string; |
|
| 189 | + if (isset($this->argument['commandCall'])) return $string; |
|
| 190 | 190 | |
| 191 | 191 | $colored_string = ""; |
| 192 | 192 | |
| 193 | 193 | // Check if given foreground color found |
| 194 | 194 | if (isset($this->foreground_colors[$foreground_color])) {
|
| 195 | - $colored_string .= "\033[" . $this->foreground_colors[$foreground_color] . "m"; |
|
| 195 | + $colored_string .= "\033[".$this->foreground_colors[$foreground_color]."m"; |
|
| 196 | 196 | } |
| 197 | 197 | // Check if given background color found |
| 198 | 198 | if (isset($this->background_colors[$background_color])) {
|
| 199 | - $colored_string .= "\033[" . $this->background_colors[$background_color] . "m"; |
|
| 199 | + $colored_string .= "\033[".$this->background_colors[$background_color]."m"; |
|
| 200 | 200 | } |
| 201 | 201 | |
| 202 | 202 | // Add string and end coloring |
| 203 | - $colored_string .= $string . "\033[0m"; |
|
| 203 | + $colored_string .= $string."\033[0m"; |
|
| 204 | 204 | |
| 205 | - return ''.$colored_string.'' . PHP_EOL; |
|
| 205 | + return ''.$colored_string.''.PHP_EOL; |
|
| 206 | 206 | } |
| 207 | 207 | |
| 208 | 208 | /** |
@@ -213,25 +213,25 @@ discard block |
||
| 213 | 213 | */ |
| 214 | 214 | public function blue($string, $foreground_color = 'white', $background_color = 'blue') |
| 215 | 215 | {
|
| 216 | - $this->consoleLogger($string,'info'); |
|
| 216 | + $this->consoleLogger($string, 'info'); |
|
| 217 | 217 | |
| 218 | - if(isset($this->argument['commandCall'])) return $string; |
|
| 218 | + if (isset($this->argument['commandCall'])) return $string; |
|
| 219 | 219 | |
| 220 | 220 | $colored_string = ""; |
| 221 | 221 | |
| 222 | 222 | // Check if given foreground color found |
| 223 | 223 | if (isset($this->foreground_colors[$foreground_color])) {
|
| 224 | - $colored_string .= "\033[" . $this->foreground_colors[$foreground_color] . "m"; |
|
| 224 | + $colored_string .= "\033[".$this->foreground_colors[$foreground_color]."m"; |
|
| 225 | 225 | } |
| 226 | 226 | // Check if given background color found |
| 227 | 227 | if (isset($this->background_colors[$background_color])) {
|
| 228 | - $colored_string .= "\033[" . $this->background_colors[$background_color] . "m"; |
|
| 228 | + $colored_string .= "\033[".$this->background_colors[$background_color]."m"; |
|
| 229 | 229 | } |
| 230 | 230 | |
| 231 | 231 | // Add string and end coloring |
| 232 | - $colored_string .= $string . "\033[0m"; |
|
| 232 | + $colored_string .= $string."\033[0m"; |
|
| 233 | 233 | |
| 234 | - return ''.$colored_string.'' . PHP_EOL; |
|
| 234 | + return ''.$colored_string.''.PHP_EOL; |
|
| 235 | 235 | } |
| 236 | 236 | |
| 237 | 237 | /** |
@@ -242,25 +242,25 @@ discard block |
||
| 242 | 242 | */ |
| 243 | 243 | public function yellow($string, $foreground_color = 'blue', $background_color = 'yellow') |
| 244 | 244 | {
|
| 245 | - $this->consoleLogger($string,'info'); |
|
| 245 | + $this->consoleLogger($string, 'info'); |
|
| 246 | 246 | |
| 247 | - if(isset($this->argument['commandCall'])) return $string; |
|
| 247 | + if (isset($this->argument['commandCall'])) return $string; |
|
| 248 | 248 | |
| 249 | 249 | $colored_string = ""; |
| 250 | 250 | |
| 251 | 251 | // Check if given foreground color found |
| 252 | 252 | if (isset($this->foreground_colors[$foreground_color])) {
|
| 253 | - $colored_string .= "\033[" . $this->foreground_colors[$foreground_color] . "m"; |
|
| 253 | + $colored_string .= "\033[".$this->foreground_colors[$foreground_color]."m"; |
|
| 254 | 254 | } |
| 255 | 255 | // Check if given background color found |
| 256 | 256 | if (isset($this->background_colors[$background_color])) {
|
| 257 | - $colored_string .= "\033[" . $this->background_colors[$background_color] . "m"; |
|
| 257 | + $colored_string .= "\033[".$this->background_colors[$background_color]."m"; |
|
| 258 | 258 | } |
| 259 | 259 | |
| 260 | 260 | // Add string and end coloring |
| 261 | - $colored_string .= $string . "\033[0m"; |
|
| 261 | + $colored_string .= $string."\033[0m"; |
|
| 262 | 262 | |
| 263 | - return ''.$colored_string.'' . PHP_EOL; |
|
| 263 | + return ''.$colored_string.''.PHP_EOL; |
|
| 264 | 264 | } |
| 265 | 265 | |
| 266 | 266 | /** |
@@ -271,25 +271,25 @@ discard block |
||
| 271 | 271 | */ |
| 272 | 272 | public function cyan($string, $foreground_color = 'magenta', $background_color = 'cyan') |
| 273 | 273 | {
|
| 274 | - $this->consoleLogger($string,'info'); |
|
| 274 | + $this->consoleLogger($string, 'info'); |
|
| 275 | 275 | |
| 276 | - if(isset($this->argument['commandCall'])) return $string; |
|
| 276 | + if (isset($this->argument['commandCall'])) return $string; |
|
| 277 | 277 | |
| 278 | 278 | $colored_string = ""; |
| 279 | 279 | |
| 280 | 280 | // Check if given foreground color found |
| 281 | 281 | if (isset($this->foreground_colors[$foreground_color])) {
|
| 282 | - $colored_string .= "\033[" . $this->foreground_colors[$foreground_color] . "m"; |
|
| 282 | + $colored_string .= "\033[".$this->foreground_colors[$foreground_color]."m"; |
|
| 283 | 283 | } |
| 284 | 284 | // Check if given background color found |
| 285 | 285 | if (isset($this->background_colors[$background_color])) {
|
| 286 | - $colored_string .= "\033[" . $this->background_colors[$background_color] . "m"; |
|
| 286 | + $colored_string .= "\033[".$this->background_colors[$background_color]."m"; |
|
| 287 | 287 | } |
| 288 | 288 | |
| 289 | 289 | // Add string and end coloring |
| 290 | - $colored_string .= $string . "\033[0m"; |
|
| 290 | + $colored_string .= $string."\033[0m"; |
|
| 291 | 291 | |
| 292 | - return ''.$colored_string.'' . PHP_EOL; |
|
| 292 | + return ''.$colored_string.''.PHP_EOL; |
|
| 293 | 293 | } |
| 294 | 294 | |
| 295 | 295 | /** |
@@ -300,23 +300,23 @@ discard block |
||
| 300 | 300 | */ |
| 301 | 301 | public function input($string, $foreground_color = 'blue', $background_color = 'light_gray') |
| 302 | 302 | {
|
| 303 | - $this->consoleLogger($string,'info'); |
|
| 303 | + $this->consoleLogger($string, 'info'); |
|
| 304 | 304 | |
| 305 | - if(isset($this->argument['commandCall'])) return $string; |
|
| 305 | + if (isset($this->argument['commandCall'])) return $string; |
|
| 306 | 306 | |
| 307 | 307 | $colored_string = ""; |
| 308 | 308 | |
| 309 | 309 | // Check if given foreground color found |
| 310 | 310 | if (isset($this->foreground_colors[$foreground_color])) {
|
| 311 | - $colored_string .= "\033[" . $this->foreground_colors[$foreground_color] . "m"; |
|
| 311 | + $colored_string .= "\033[".$this->foreground_colors[$foreground_color]."m"; |
|
| 312 | 312 | } |
| 313 | 313 | // Check if given background color found |
| 314 | 314 | if (isset($this->background_colors[$background_color])) {
|
| 315 | - $colored_string .= "\033[" . $this->background_colors[$background_color] . "m"; |
|
| 315 | + $colored_string .= "\033[".$this->background_colors[$background_color]."m"; |
|
| 316 | 316 | } |
| 317 | 317 | |
| 318 | 318 | // Add string and end coloring |
| 319 | - $colored_string .= $string . "\033[0m"; |
|
| 319 | + $colored_string .= $string."\033[0m"; |
|
| 320 | 320 | |
| 321 | 321 | return ''.$colored_string.''; |
| 322 | 322 | } |
@@ -329,24 +329,24 @@ discard block |
||
| 329 | 329 | */ |
| 330 | 330 | public function error($string, $foreground_color = 'white', $background_color = 'red') |
| 331 | 331 | {
|
| 332 | - $this->consoleLogger($string,'error'); |
|
| 332 | + $this->consoleLogger($string, 'error'); |
|
| 333 | 333 | |
| 334 | - if(isset($this->argument['commandCall'])) return $string; |
|
| 334 | + if (isset($this->argument['commandCall'])) return $string; |
|
| 335 | 335 | |
| 336 | 336 | $colored_string = ""; |
| 337 | 337 | |
| 338 | 338 | // Check if given foreground color found |
| 339 | 339 | if (isset($this->foreground_colors[$foreground_color])) {
|
| 340 | - $colored_string .= "\033[" . $this->foreground_colors[$foreground_color] . "m"; |
|
| 340 | + $colored_string .= "\033[".$this->foreground_colors[$foreground_color]."m"; |
|
| 341 | 341 | } |
| 342 | 342 | // Check if given background color found |
| 343 | 343 | if (isset($this->background_colors[$background_color])) {
|
| 344 | - $colored_string .= "\033[" . $this->background_colors[$background_color] . "m"; |
|
| 344 | + $colored_string .= "\033[".$this->background_colors[$background_color]."m"; |
|
| 345 | 345 | } |
| 346 | 346 | |
| 347 | 347 | // Add string and end coloring |
| 348 | - $colored_string .= "!!!! Error : ".$string . " \033[0m"; |
|
| 348 | + $colored_string .= "!!!! Error : ".$string." \033[0m"; |
|
| 349 | 349 | |
| 350 | - return ''.$colored_string.'' . PHP_EOL; |
|
| 350 | + return ''.$colored_string.''.PHP_EOL; |
|
| 351 | 351 | } |
| 352 | 352 | } |
| 353 | 353 | \ No newline at end of file |
@@ -15,7 +15,9 @@ discard block |
||
| 15 | 15 | {
|
| 16 | 16 | $this->consoleLogger($string,'info'); |
| 17 | 17 | |
| 18 | - if(isset($this->argument['commandCall'])) return $string; |
|
| 18 | + if(isset($this->argument['commandCall'])) {
|
|
| 19 | + return $string; |
|
| 20 | + } |
|
| 19 | 21 | |
| 20 | 22 | $colored_string = ""; |
| 21 | 23 | |
@@ -45,7 +47,9 @@ discard block |
||
| 45 | 47 | {
|
| 46 | 48 | $this->consoleLogger($string,'info'); |
| 47 | 49 | |
| 48 | - if(isset($this->argument['commandCall'])) return $string; |
|
| 50 | + if(isset($this->argument['commandCall'])) {
|
|
| 51 | + return $string; |
|
| 52 | + } |
|
| 49 | 53 | |
| 50 | 54 | $colored_string = ""; |
| 51 | 55 | |
@@ -73,7 +77,9 @@ discard block |
||
| 73 | 77 | {
|
| 74 | 78 | $this->consoleLogger($string,'info'); |
| 75 | 79 | |
| 76 | - if(isset($this->argument['commandCall'])) return $string; |
|
| 80 | + if(isset($this->argument['commandCall'])) {
|
|
| 81 | + return $string; |
|
| 82 | + } |
|
| 77 | 83 | |
| 78 | 84 | $colored_string = ""; |
| 79 | 85 | |
@@ -99,7 +105,9 @@ discard block |
||
| 99 | 105 | {
|
| 100 | 106 | $this->consoleLogger($string,'info'); |
| 101 | 107 | |
| 102 | - if(isset($this->argument['commandCall'])) return $string; |
|
| 108 | + if(isset($this->argument['commandCall'])) {
|
|
| 109 | + return $string; |
|
| 110 | + } |
|
| 103 | 111 | |
| 104 | 112 | $colored_string = ""; |
| 105 | 113 | |
@@ -128,7 +136,9 @@ discard block |
||
| 128 | 136 | {
|
| 129 | 137 | $this->consoleLogger($string,'info'); |
| 130 | 138 | |
| 131 | - if(isset($this->argument['commandCall'])) return $string; |
|
| 139 | + if(isset($this->argument['commandCall'])) {
|
|
| 140 | + return $string; |
|
| 141 | + } |
|
| 132 | 142 | |
| 133 | 143 | $colored_string = ""; |
| 134 | 144 | |
@@ -157,7 +167,9 @@ discard block |
||
| 157 | 167 | {
|
| 158 | 168 | $this->consoleLogger($string,'info'); |
| 159 | 169 | |
| 160 | - if(isset($this->argument['commandCall'])) return $string; |
|
| 170 | + if(isset($this->argument['commandCall'])) {
|
|
| 171 | + return $string; |
|
| 172 | + } |
|
| 161 | 173 | |
| 162 | 174 | $colored_string = ""; |
| 163 | 175 | |
@@ -186,7 +198,9 @@ discard block |
||
| 186 | 198 | {
|
| 187 | 199 | $this->consoleLogger($string,'info'); |
| 188 | 200 | |
| 189 | - if(isset($this->argument['commandCall'])) return $string; |
|
| 201 | + if(isset($this->argument['commandCall'])) {
|
|
| 202 | + return $string; |
|
| 203 | + } |
|
| 190 | 204 | |
| 191 | 205 | $colored_string = ""; |
| 192 | 206 | |
@@ -215,7 +229,9 @@ discard block |
||
| 215 | 229 | {
|
| 216 | 230 | $this->consoleLogger($string,'info'); |
| 217 | 231 | |
| 218 | - if(isset($this->argument['commandCall'])) return $string; |
|
| 232 | + if(isset($this->argument['commandCall'])) {
|
|
| 233 | + return $string; |
|
| 234 | + } |
|
| 219 | 235 | |
| 220 | 236 | $colored_string = ""; |
| 221 | 237 | |
@@ -244,7 +260,9 @@ discard block |
||
| 244 | 260 | {
|
| 245 | 261 | $this->consoleLogger($string,'info'); |
| 246 | 262 | |
| 247 | - if(isset($this->argument['commandCall'])) return $string; |
|
| 263 | + if(isset($this->argument['commandCall'])) {
|
|
| 264 | + return $string; |
|
| 265 | + } |
|
| 248 | 266 | |
| 249 | 267 | $colored_string = ""; |
| 250 | 268 | |
@@ -273,7 +291,9 @@ discard block |
||
| 273 | 291 | {
|
| 274 | 292 | $this->consoleLogger($string,'info'); |
| 275 | 293 | |
| 276 | - if(isset($this->argument['commandCall'])) return $string; |
|
| 294 | + if(isset($this->argument['commandCall'])) {
|
|
| 295 | + return $string; |
|
| 296 | + } |
|
| 277 | 297 | |
| 278 | 298 | $colored_string = ""; |
| 279 | 299 | |
@@ -302,7 +322,9 @@ discard block |
||
| 302 | 322 | {
|
| 303 | 323 | $this->consoleLogger($string,'info'); |
| 304 | 324 | |
| 305 | - if(isset($this->argument['commandCall'])) return $string; |
|
| 325 | + if(isset($this->argument['commandCall'])) {
|
|
| 326 | + return $string; |
|
| 327 | + } |
|
| 306 | 328 | |
| 307 | 329 | $colored_string = ""; |
| 308 | 330 | |
@@ -331,7 +353,9 @@ discard block |
||
| 331 | 353 | {
|
| 332 | 354 | $this->consoleLogger($string,'error'); |
| 333 | 355 | |
| 334 | - if(isset($this->argument['commandCall'])) return $string; |
|
| 356 | + if(isset($this->argument['commandCall'])) {
|
|
| 357 | + return $string; |
|
| 358 | + } |
|
| 335 | 359 | |
| 336 | 360 | $colored_string = ""; |
| 337 | 361 | |
@@ -17,7 +17,7 @@ |
||
| 17 | 17 | * @param $offset |
| 18 | 18 | * @param $value |
| 19 | 19 | */ |
| 20 | - final public function offsetSet($offset,$value) |
|
| 20 | + final public function offsetSet($offset, $value) |
|
| 21 | 21 | {
|
| 22 | 22 | $this->{$offset} = $value;
|
| 23 | 23 | } |
@@ -56,8 +56,8 @@ discard block |
||
| 56 | 56 | */ |
| 57 | 57 | public function resolveMethod($method) |
| 58 | 58 | {
|
| 59 | - $method=str_replace(httpMethod(),'',$method); |
|
| 60 | - $method=str_replace(StaticPathModel::$methodPrefix,'',$method); |
|
| 59 | + $method = str_replace(httpMethod(), '', $method); |
|
| 60 | + $method = str_replace(StaticPathModel::$methodPrefix, '', $method); |
|
| 61 | 61 | return $method; |
| 62 | 62 | } |
| 63 | 63 | |
@@ -105,16 +105,16 @@ discard block |
||
| 105 | 105 | //If controller does not have a method after checking whether the method specified in the controller class exists, |
| 106 | 106 | //then by default we assign a default method value of indexAction. |
| 107 | 107 | //This value must match the class strictly, otherwise the controller can not be called |
| 108 | - if(method_exists($this->app['instanceController'],$this->getPrefixMethod())){
|
|
| 108 | + if (method_exists($this->app['instanceController'], $this->getPrefixMethod())) {
|
|
| 109 | 109 | |
| 110 | 110 | //method value as normal |
| 111 | - return $this->setViaDefine($this->getPrefixMethod(),$globalInstance); |
|
| 111 | + return $this->setViaDefine($this->getPrefixMethod(), $globalInstance); |
|
| 112 | 112 | } |
| 113 | 113 | |
| 114 | 114 | //by default we assign a default method value of indexAction |
| 115 | 115 | //this value must be a method value automatically named indexAction |
| 116 | 116 | //if it does not come from the url discovery value |
| 117 | - return $this->setViaDefine($this->getPrefixIndexMethod(),$globalInstance); |
|
| 117 | + return $this->setViaDefine($this->getPrefixIndexMethod(), $globalInstance); |
|
| 118 | 118 | } |
| 119 | 119 | |
| 120 | 120 | /** |
@@ -125,7 +125,7 @@ discard block |
||
| 125 | 125 | {
|
| 126 | 126 | //If the path variables give values in the methods do we have a method name, |
| 127 | 127 | //we subtract this value from the route variables. |
| 128 | - return array_values(array_diff(core()->routeParameters,[$method])); |
|
| 128 | + return array_values(array_diff(core()->routeParameters, [$method])); |
|
| 129 | 129 | } |
| 130 | 130 | |
| 131 | 131 | /** |
@@ -133,12 +133,12 @@ discard block |
||
| 133 | 133 | * @param $globalInstance Router |
| 134 | 134 | * @return mixed |
| 135 | 135 | */ |
| 136 | - private function setViaDefine($method,$globalInstance) |
|
| 136 | + private function setViaDefine($method, $globalInstance) |
|
| 137 | 137 | {
|
| 138 | 138 | // we are extracting httpMethod and prefix from |
| 139 | 139 | // the method variable so that we can extract the salt method name. |
| 140 | - $deleteHttp = str_replace(httpMethod(),'',$method); |
|
| 141 | - $methodName = str_replace(StaticPathModel::$methodPrefix,'',$deleteHttp); |
|
| 140 | + $deleteHttp = str_replace(httpMethod(), '', $method); |
|
| 141 | + $methodName = str_replace(StaticPathModel::$methodPrefix, '', $deleteHttp); |
|
| 142 | 142 | |
| 143 | 143 | //set as global method name |
| 144 | 144 | $globalInstance->setMethodNameViaDefine($methodName); |
@@ -156,19 +156,19 @@ discard block |
||
| 156 | 156 | $fromRoutes = Route::getRouteResolve(); |
| 157 | 157 | $namespace = null; |
| 158 | 158 | |
| 159 | - if(count($fromRoutes)){
|
|
| 160 | - $fromRoutesClass = (isset($fromRoutes['class'])) ? $fromRoutes['class'] : null; |
|
| 159 | + if (count($fromRoutes)) {
|
|
| 160 | + $fromRoutesClass = (isset($fromRoutes['class'])) ? $fromRoutes['class'] : null; |
|
| 161 | 161 | |
| 162 | - if($fromRoutes['namespace']===null){
|
|
| 162 | + if ($fromRoutes['namespace']===null) {
|
|
| 163 | 163 | $namespace = Utils::getNamespace($fromRoutes['controller']).'\\'.$fromRoutesClass; |
| 164 | 164 | } |
| 165 | - else{
|
|
| 165 | + else {
|
|
| 166 | 166 | $namespace = Utils::getNamespace($fromRoutes['controller']).'\\'.$fromRoutes['namespace'].'\\'.$fromRoutesClass; |
| 167 | 167 | } |
| 168 | 168 | } |
| 169 | 169 | |
| 170 | 170 | //check namespace exists |
| 171 | - if(file_exists(Utils::getPathFromNamespace($namespace)) && Utils::isNamespaceExists($namespace)){
|
|
| 171 | + if (file_exists(Utils::getPathFromNamespace($namespace)) && Utils::isNamespaceExists($namespace)) {
|
|
| 172 | 172 | |
| 173 | 173 | // the controller classes are registered in the config controller. |
| 174 | 174 | // the controller class is not executed if it is not available here. |
@@ -188,7 +188,7 @@ discard block |
||
| 188 | 188 | public function checkAutoService($instance) |
| 189 | 189 | {
|
| 190 | 190 | //If auto service is present, this auto service will be accepted as endpoint namespace. |
| 191 | - return $this->checkEndpointForAutoService()->getNamespaceForAutoService($instance,function(){
|
|
| 191 | + return $this->checkEndpointForAutoService()->getNamespaceForAutoService($instance, function() {
|
|
| 192 | 192 | throw new \UnexpectedValueException('Any endpoint is not available');
|
| 193 | 193 | }); |
| 194 | 194 | } |
@@ -200,19 +200,19 @@ discard block |
||
| 200 | 200 | {
|
| 201 | 201 | $configController = config('controller');
|
| 202 | 202 | |
| 203 | - if($configController===null |
|
| 203 | + if ($configController===null |
|
| 204 | 204 | OR !isset($configController[$this->endpoint()]) |
| 205 | - or !isset($configController[$this->endpoint()][$namespace])){
|
|
| 205 | + or !isset($configController[$this->endpoint()][$namespace])) {
|
|
| 206 | 206 | exception()->badFunctionCall('The request has not been saved in your configuration settings.');
|
| 207 | 207 | } |
| 208 | 208 | |
| 209 | 209 | $configController = $configController[$this->endpoint()][$namespace]; |
| 210 | 210 | |
| 211 | - if(isset($configController[environment()]) and $configController[environment()]===false){
|
|
| 211 | + if (isset($configController[environment()]) and $configController[environment()]===false) {
|
|
| 212 | 212 | exception()->domain('Sorry, this endpoint is not allowed to run for this environment.');
|
| 213 | 213 | } |
| 214 | 214 | |
| 215 | - if(isset($configController['all']) AND $configController['all']===false){
|
|
| 215 | + if (isset($configController['all']) AND $configController['all']===false) {
|
|
| 216 | 216 | exception()->domain('Sorry, this endpoint is never allowed to run.');
|
| 217 | 217 | } |
| 218 | 218 | } |
@@ -161,8 +161,7 @@ |
||
| 161 | 161 | |
| 162 | 162 | if($fromRoutes['namespace']===null){
|
| 163 | 163 | $namespace = Utils::getNamespace($fromRoutes['controller']).'\\'.$fromRoutesClass; |
| 164 | - } |
|
| 165 | - else{
|
|
| 164 | + } else{
|
|
| 166 | 165 | $namespace = Utils::getNamespace($fromRoutes['controller']).'\\'.$fromRoutes['namespace'].'\\'.$fromRoutesClass; |
| 167 | 166 | } |
| 168 | 167 | } |
@@ -46,8 +46,7 @@ discard block |
||
| 46 | 46 | if(isset(core()->exceptiontrace)) |
| 47 | 47 | {
|
| 48 | 48 | $this->data['status'] = (int)core()->exceptiontrace['callNamespace']->getCode(); |
| 49 | - } |
|
| 50 | - else {
|
|
| 49 | + } else {
|
|
| 51 | 50 | |
| 52 | 51 | $this->data['status']=(int)$exception::exceptionTypeCodes($this->data['errType']); |
| 53 | 52 | } |
@@ -139,8 +138,7 @@ discard block |
||
| 139 | 138 | |
| 140 | 139 | //set as the success object is false |
| 141 | 140 | $this->data['appExceptionSuccess']=[]; |
| 142 | - } |
|
| 143 | - else{
|
|
| 141 | + } else{
|
|
| 144 | 142 | |
| 145 | 143 | //set as the success object is false |
| 146 | 144 | $this->data['appExceptionSuccess']=['success'=>(bool)false,'status'=>$this->data['status']]; |
@@ -176,8 +174,7 @@ discard block |
||
| 176 | 174 | $this->app->register('responseStatus',500);
|
| 177 | 175 | |
| 178 | 176 | |
| 179 | - } |
|
| 180 | - else{
|
|
| 177 | + } else{
|
|
| 181 | 178 | |
| 182 | 179 | $appException=$this->getAppException($environment,$this->data['errStrReal']); |
| 183 | 180 | |
@@ -210,8 +207,7 @@ discard block |
||
| 210 | 207 | |
| 211 | 208 | echo json_encode(core()->out->outputFormatter($appException)); |
| 212 | 209 | exit(); |
| 213 | - } |
|
| 214 | - else{
|
|
| 210 | + } else{
|
|
| 215 | 211 | echo $restaOutHandle; |
| 216 | 212 | exit(); |
| 217 | 213 | } |
@@ -321,8 +317,7 @@ discard block |
||
| 321 | 317 | |
| 322 | 318 | if($lang!==null){
|
| 323 | 319 | $langMessage=trans('exception.'.$lang);
|
| 324 | - } |
|
| 325 | - else{
|
|
| 320 | + } else{
|
|
| 326 | 321 | $langMessage=null; |
| 327 | 322 | } |
| 328 | 323 | |
@@ -352,8 +347,7 @@ discard block |
||
| 352 | 347 | |
| 353 | 348 | if($this->data['errType']==="Undefined"){
|
| 354 | 349 | $this->data['errStrReal']=$this->data['errStrReal']; |
| 355 | - } |
|
| 356 | - else{
|
|
| 350 | + } else{
|
|
| 357 | 351 | $this->data['errContext']['trace']=$this->data['errStrReal']; |
| 358 | 352 | } |
| 359 | 353 | } |
@@ -24,12 +24,12 @@ discard block |
||
| 24 | 24 | /** |
| 25 | 25 | * @var $data array |
| 26 | 26 | */ |
| 27 | - protected $data=array(); |
|
| 27 | + protected $data = array(); |
|
| 28 | 28 | |
| 29 | 29 | /** |
| 30 | 30 | * @return mixed|string |
| 31 | 31 | */ |
| 32 | - private function getEnvironmentStatus(){
|
|
| 32 | + private function getEnvironmentStatus() {
|
|
| 33 | 33 | |
| 34 | 34 | // application key, but if it has a null value |
| 35 | 35 | // then we move the environment value to the production environment. |
@@ -39,41 +39,41 @@ discard block |
||
| 39 | 39 | /** |
| 40 | 40 | * @return void|mixed |
| 41 | 41 | */ |
| 42 | - private function getStatusFromContext(){
|
|
| 42 | + private function getStatusFromContext() {
|
|
| 43 | 43 | |
| 44 | - $exception=$this->exception; |
|
| 44 | + $exception = $this->exception; |
|
| 45 | 45 | |
| 46 | - if(isset(core()->exceptiontrace)) |
|
| 46 | + if (isset(core()->exceptiontrace)) |
|
| 47 | 47 | {
|
| 48 | 48 | $this->data['status'] = (int)core()->exceptiontrace['callNamespace']->getCode(); |
| 49 | 49 | } |
| 50 | 50 | else {
|
| 51 | 51 | |
| 52 | - $this->data['status']=(int)$exception::exceptionTypeCodes($this->data['errType']); |
|
| 52 | + $this->data['status'] = (int)$exception::exceptionTypeCodes($this->data['errType']); |
|
| 53 | 53 | } |
| 54 | 54 | |
| 55 | 55 | $this->app->terminate('responseSuccess');
|
| 56 | 56 | $this->app->terminate('responseStatus');
|
| 57 | - $this->app->register('responseSuccess',(bool)false);
|
|
| 58 | - $this->app->register('responseStatus',$this->data['status']);
|
|
| 57 | + $this->app->register('responseSuccess', (bool)false);
|
|
| 58 | + $this->app->register('responseStatus', $this->data['status']);
|
|
| 59 | 59 | |
| 60 | 60 | |
| 61 | - $optionalException=str_replace("\\","\\\\",$this->app->namespace()->exception());
|
|
| 61 | + $optionalException = str_replace("\\", "\\\\", $this->app->namespace()->exception());
|
|
| 62 | 62 | |
| 63 | - if(preg_match('@'.$optionalException.'@is',$this->data['errType'])){
|
|
| 63 | + if (preg_match('@'.$optionalException.'@is', $this->data['errType'])) {
|
|
| 64 | 64 | |
| 65 | 65 | //linux test |
| 66 | - $trace=$this->data['errContext']['trace']; |
|
| 67 | - if(preg_match('@Stack trace:\n#0(.*)\n#1@is',$trace,$traceArray)){
|
|
| 68 | - $traceFile=str_replace(root,'',$traceArray[1]); |
|
| 69 | - if(preg_match('@(.*)\((\d+)\)@is',$traceFile,$traceResolve)){
|
|
| 70 | - $this->data['errFile']=$traceResolve[1]; |
|
| 71 | - $this->data['errLine']=(int)$traceResolve[2]; |
|
| 66 | + $trace = $this->data['errContext']['trace']; |
|
| 67 | + if (preg_match('@Stack trace:\n#0(.*)\n#1@is', $trace, $traceArray)) {
|
|
| 68 | + $traceFile = str_replace(root, '', $traceArray[1]); |
|
| 69 | + if (preg_match('@(.*)\((\d+)\)@is', $traceFile, $traceResolve)) {
|
|
| 70 | + $this->data['errFile'] = $traceResolve[1]; |
|
| 71 | + $this->data['errLine'] = (int)$traceResolve[2]; |
|
| 72 | 72 | } |
| 73 | 73 | } |
| 74 | 74 | |
| 75 | 75 | |
| 76 | - $this->data['errType']=class_basename($this->data['errType']); |
|
| 76 | + $this->data['errType'] = class_basename($this->data['errType']); |
|
| 77 | 77 | } |
| 78 | 78 | } |
| 79 | 79 | |
@@ -89,18 +89,18 @@ discard block |
||
| 89 | 89 | // in general we will use the exception class |
| 90 | 90 | // in the store/config directory to make it possible |
| 91 | 91 | // to change the user-based exceptions. |
| 92 | - $this->exception=StaticPathModel::$store.'\Config\Exception'; |
|
| 92 | + $this->exception = StaticPathModel::$store.'\Config\Exception'; |
|
| 93 | 93 | |
| 94 | 94 | //This function can be used for defining your own way of handling errors during runtime, |
| 95 | 95 | //for example in applications in which you need to do cleanup of data/files when a critical error happens, |
| 96 | 96 | //or when you need to trigger an error under certain conditions (using trigger_error()). |
| 97 | - set_error_handler([$this,'setErrorHandler']); |
|
| 97 | + set_error_handler([$this, 'setErrorHandler']); |
|
| 98 | 98 | |
| 99 | 99 | //Registers a callback to be executed after script execution finishes or exit() is called. |
| 100 | 100 | //Multiple calls to register_shutdown_function() can be made, and each will be called in the same order as |
| 101 | 101 | //they were registered. If you call exit() within one registered shutdown function, |
| 102 | 102 | //processing will stop completely and no other registered shutdown functions will be called. |
| 103 | - register_shutdown_function([$this,'fatalErrorShutdownHandler']); |
|
| 103 | + register_shutdown_function([$this, 'fatalErrorShutdownHandler']); |
|
| 104 | 104 | } |
| 105 | 105 | |
| 106 | 106 | /** |
@@ -110,7 +110,7 @@ discard block |
||
| 110 | 110 | * @param null $errLine |
| 111 | 111 | * @param null $errContext |
| 112 | 112 | */ |
| 113 | - public function setErrorHandler($errNo=null, $errStr=null, $errFile=null, $errLine=null, $errContext=null) |
|
| 113 | + public function setErrorHandler($errNo = null, $errStr = null, $errFile = null, $errLine = null, $errContext = null) |
|
| 114 | 114 | {
|
| 115 | 115 | // in case of a deficiency, |
| 116 | 116 | // we need to boot our general needs to be needed for the exception. |
@@ -135,79 +135,78 @@ discard block |
||
| 135 | 135 | |
| 136 | 136 | $this->getStatusFromContext(); |
| 137 | 137 | |
| 138 | - if(is_array($meta=config('response.meta'))){
|
|
| 138 | + if (is_array($meta = config('response.meta'))) {
|
|
| 139 | 139 | |
| 140 | 140 | //set as the success object is false |
| 141 | - $this->data['appExceptionSuccess']=[]; |
|
| 141 | + $this->data['appExceptionSuccess'] = []; |
|
| 142 | 142 | } |
| 143 | - else{
|
|
| 143 | + else {
|
|
| 144 | 144 | |
| 145 | 145 | //set as the success object is false |
| 146 | - $this->data['appExceptionSuccess']=['success'=>(bool)false,'status'=>$this->data['status']]; |
|
| 146 | + $this->data['appExceptionSuccess'] = ['success'=>(bool)false, 'status'=>$this->data['status']]; |
|
| 147 | 147 | } |
| 148 | 148 | |
| 149 | 149 | //get lang message for exception |
| 150 | 150 | $this->getLangMessageForException(); |
| 151 | 151 | |
| 152 | - if(property_exists(core(),'exceptiontrace')){
|
|
| 152 | + if (property_exists(core(), 'exceptiontrace')) {
|
|
| 153 | 153 | |
| 154 | - $customExceptionTrace=core()->exceptiontrace; |
|
| 155 | - $this->data['errFile']=$customExceptionTrace['file']; |
|
| 156 | - $this->data['errLine']=$customExceptionTrace['line']; |
|
| 154 | + $customExceptionTrace = core()->exceptiontrace; |
|
| 155 | + $this->data['errFile'] = $customExceptionTrace['file']; |
|
| 156 | + $this->data['errLine'] = $customExceptionTrace['line']; |
|
| 157 | 157 | } |
| 158 | 158 | |
| 159 | 159 | $environment = $this->getEnvironmentStatus(); |
| 160 | 160 | |
| 161 | - $vendorDirectory = str_replace(root.''.DIRECTORY_SEPARATOR.'','',$this->data['errFile']); |
|
| 161 | + $vendorDirectory = str_replace(root.''.DIRECTORY_SEPARATOR.'', '', $this->data['errFile']); |
|
| 162 | 162 | |
| 163 | - if(Str::startsWith($vendorDirectory,'vendor') |
|
| 164 | - && Str::startsWith($vendorDirectory,'vendor/php-resta')===false) |
|
| 163 | + if (Str::startsWith($vendorDirectory, 'vendor') |
|
| 164 | + && Str::startsWith($vendorDirectory, 'vendor/php-resta')===false) |
|
| 165 | 165 | {
|
| 166 | 166 | $externalMessage = ($environment==="production") ? |
| 167 | - 'An unexpected external error has occurred' : |
|
| 168 | - $this->data['errStrReal']; |
|
| 167 | + 'An unexpected external error has occurred' : $this->data['errStrReal']; |
|
| 169 | 168 | |
| 170 | - $appException=$this->getAppException($environment,$externalMessage); |
|
| 169 | + $appException = $this->getAppException($environment, $externalMessage); |
|
| 171 | 170 | |
| 172 | 171 | |
| 173 | 172 | //Get or Set the HTTP response code |
| 174 | 173 | http_response_code(500); |
| 175 | 174 | $this->app->terminate('responseStatus');
|
| 176 | - $this->app->register('responseStatus',500);
|
|
| 175 | + $this->app->register('responseStatus', 500);
|
|
| 177 | 176 | |
| 178 | 177 | |
| 179 | 178 | } |
| 180 | - else{
|
|
| 179 | + else {
|
|
| 181 | 180 | |
| 182 | - $appException=$this->getAppException($environment,$this->data['errStrReal']); |
|
| 181 | + $appException = $this->getAppException($environment, $this->data['errStrReal']); |
|
| 183 | 182 | |
| 184 | 183 | //Get or Set the HTTP response code |
| 185 | 184 | http_response_code($this->data['status']); |
| 186 | 185 | } |
| 187 | 186 | |
| 188 | 187 | |
| 189 | - if($environment==="production"){
|
|
| 188 | + if ($environment==="production") {
|
|
| 190 | 189 | |
| 191 | - $productionLogMessage = $this->getAppException('local',$this->data['errStrReal']);
|
|
| 192 | - $this->app->register('productionLogMessage',core()->out->outputFormatter($productionLogMessage));
|
|
| 190 | + $productionLogMessage = $this->getAppException('local', $this->data['errStrReal']);
|
|
| 191 | + $this->app->register('productionLogMessage', core()->out->outputFormatter($productionLogMessage));
|
|
| 193 | 192 | } |
| 194 | 193 | |
| 195 | - if(app()->has('requestExpected') && config('app.requestWithError')===true){
|
|
| 194 | + if (app()->has('requestExpected') && config('app.requestWithError')===true) {
|
|
| 196 | 195 | $appException['request']['expected'] = app()->get('requestExpected');
|
| 197 | 196 | } |
| 198 | 197 | |
| 199 | 198 | |
| 200 | 199 | //set json app exception |
| 201 | - core()->routerResult=$appException; |
|
| 200 | + core()->routerResult = $appException; |
|
| 202 | 201 | |
| 203 | 202 | $restaOutHandle = null; |
| 204 | 203 | |
| 205 | - if(!defined('responseApp')){
|
|
| 204 | + if (!defined('responseApp')) {
|
|
| 206 | 205 | |
| 207 | - $restaOutHandle=core()->out->handle(); |
|
| 206 | + $restaOutHandle = core()->out->handle(); |
|
| 208 | 207 | } |
| 209 | 208 | |
| 210 | - if($restaOutHandle===null){
|
|
| 209 | + if ($restaOutHandle===null) {
|
|
| 211 | 210 | |
| 212 | 211 | //header set and symfony response call |
| 213 | 212 | header('Content-type:application/json;charset=utf-8');
|
@@ -215,7 +214,7 @@ discard block |
||
| 215 | 214 | echo json_encode(core()->out->outputFormatter($appException)); |
| 216 | 215 | exit(); |
| 217 | 216 | } |
| 218 | - else{
|
|
| 217 | + else {
|
|
| 219 | 218 | echo $restaOutHandle; |
| 220 | 219 | exit(); |
| 221 | 220 | } |
@@ -226,7 +225,7 @@ discard block |
||
| 226 | 225 | * @param $environment |
| 227 | 226 | * @return mixed |
| 228 | 227 | */ |
| 229 | - private function getAppException($environment,$message) |
|
| 228 | + private function getAppException($environment, $message) |
|
| 230 | 229 | {
|
| 231 | 230 | return $this->data['appExceptionSuccess']+$this->data['exception']::$environment( |
| 232 | 231 | $this->data['errNo'], |
@@ -244,18 +243,18 @@ discard block |
||
| 244 | 243 | public function fatalErrorShutdownHandler() |
| 245 | 244 | {
|
| 246 | 245 | //get fatal error |
| 247 | - $last_error =error_get_last(); |
|
| 246 | + $last_error = error_get_last(); |
|
| 248 | 247 | |
| 249 | 248 | $this->inStactTrace($last_error); |
| 250 | 249 | |
| 251 | - if($last_error!==null){
|
|
| 250 | + if ($last_error!==null) {
|
|
| 252 | 251 | |
| 253 | - if(!defined('methodName')){
|
|
| 252 | + if (!defined('methodName')) {
|
|
| 254 | 253 | |
| 255 | - define('methodName',null);
|
|
| 254 | + define('methodName', null);
|
|
| 256 | 255 | } |
| 257 | 256 | |
| 258 | - if(isset(core()->exceptionFile)){
|
|
| 257 | + if (isset(core()->exceptionFile)) {
|
|
| 259 | 258 | $last_error['file'] = core()->exceptionFile; |
| 260 | 259 | $last_error['line'] = core()->exceptionLine; |
| 261 | 260 | } |
@@ -275,12 +274,12 @@ discard block |
||
| 275 | 274 | */ |
| 276 | 275 | public function inStactTrace($error) |
| 277 | 276 | {
|
| 278 | - if(isset(core()->urlComponent)){
|
|
| 279 | - if(!preg_match('@'.core()->urlComponent['project'].'@',$error['file']) && !isset(core()->exceptionFile)){
|
|
| 280 | - if(preg_match('@ in\s(.*?)\n@is',$error['message'],$result)){
|
|
| 281 | - $errorMessage = explode(":",$result[1]);
|
|
| 282 | - $this->app->register('exceptionFile',$errorMessage[0]);
|
|
| 283 | - $this->app->register('exceptionLine',$errorMessage[1]);
|
|
| 277 | + if (isset(core()->urlComponent)) {
|
|
| 278 | + if (!preg_match('@'.core()->urlComponent['project'].'@', $error['file']) && !isset(core()->exceptionFile)) {
|
|
| 279 | + if (preg_match('@ in\s(.*?)\n@is', $error['message'], $result)) {
|
|
| 280 | + $errorMessage = explode(":", $result[1]);
|
|
| 281 | + $this->app->register('exceptionFile', $errorMessage[0]);
|
|
| 282 | + $this->app->register('exceptionLine', $errorMessage[1]);
|
|
| 284 | 283 | } |
| 285 | 284 | } |
| 286 | 285 | } |
@@ -289,76 +288,76 @@ discard block |
||
| 289 | 288 | /** |
| 290 | 289 | * @return void|mixed |
| 291 | 290 | */ |
| 292 | - private function getLangMessageForException(){
|
|
| 291 | + private function getLangMessageForException() {
|
|
| 293 | 292 | |
| 294 | 293 | $clone = clone $this; |
| 295 | 294 | |
| 296 | - if(property_exists(core(),'exceptionTranslate')){
|
|
| 295 | + if (property_exists(core(), 'exceptionTranslate')) {
|
|
| 297 | 296 | |
| 298 | - $langMessage=trans('exception.'.core()->exceptionTranslate);
|
|
| 297 | + $langMessage = trans('exception.'.core()->exceptionTranslate);
|
|
| 299 | 298 | |
| 300 | - if(!is_null($langMessage) && property_exists(core(),'exceptionTranslateParams')){
|
|
| 299 | + if (!is_null($langMessage) && property_exists(core(), 'exceptionTranslateParams')) {
|
|
| 301 | 300 | |
| 302 | - if(count(core()->exceptionTranslateParams[core()->exceptionTranslate])){
|
|
| 303 | - foreach (core()->exceptionTranslateParams[core()->exceptionTranslate] as $key=>$value){
|
|
| 304 | - $langMessage=preg_replace('@\('.$key.'\)@is',$value,$langMessage);
|
|
| 301 | + if (count(core()->exceptionTranslateParams[core()->exceptionTranslate])) {
|
|
| 302 | + foreach (core()->exceptionTranslateParams[core()->exceptionTranslate] as $key=>$value) {
|
|
| 303 | + $langMessage = preg_replace('@\('.$key.'\)@is', $value, $langMessage);
|
|
| 305 | 304 | } |
| 306 | 305 | } |
| 307 | 306 | } |
| 308 | 307 | |
| 309 | - if($langMessage!==null){
|
|
| 310 | - $this->data['errStrReal']=$langMessage; |
|
| 308 | + if ($langMessage!==null) {
|
|
| 309 | + $this->data['errStrReal'] = $langMessage; |
|
| 311 | 310 | } |
| 312 | 311 | } |
| 313 | 312 | |
| 314 | - if(class_exists($this->data['errorClassNamespace']) |
|
| 315 | - && Str::startsWith($this->data['errorClassNamespace'],'App')){
|
|
| 313 | + if (class_exists($this->data['errorClassNamespace']) |
|
| 314 | + && Str::startsWith($this->data['errorClassNamespace'], 'App')) {
|
|
| 316 | 315 | |
| 317 | 316 | ClosureDispatcher::bind($this->data['errorClassNamespace'])->call(function() use ($clone) {
|
| 318 | - if(property_exists($this,'lang')){
|
|
| 319 | - $clone->lang=$this->lang; |
|
| 317 | + if (property_exists($this, 'lang')) {
|
|
| 318 | + $clone->lang = $this->lang; |
|
| 320 | 319 | } |
| 321 | 320 | }); |
| 322 | 321 | } |
| 323 | 322 | |
| 324 | - $this->data['lang']=$lang=$clone->lang; |
|
| 323 | + $this->data['lang'] = $lang = $clone->lang; |
|
| 325 | 324 | |
| 326 | - if($lang!==null){
|
|
| 327 | - $langMessage=trans('exception.'.$lang);
|
|
| 325 | + if ($lang!==null) {
|
|
| 326 | + $langMessage = trans('exception.'.$lang);
|
|
| 328 | 327 | } |
| 329 | - else{
|
|
| 330 | - $langMessage=null; |
|
| 328 | + else {
|
|
| 329 | + $langMessage = null; |
|
| 331 | 330 | } |
| 332 | 331 | |
| 333 | 332 | |
| 334 | - if($langMessage!==null){
|
|
| 335 | - $this->data['errStrReal']=$langMessage; |
|
| 333 | + if ($langMessage!==null) {
|
|
| 334 | + $this->data['errStrReal'] = $langMessage; |
|
| 336 | 335 | } |
| 337 | 336 | } |
| 338 | 337 | |
| 339 | 338 | /** |
| 340 | 339 | * @return void|mixed |
| 341 | 340 | */ |
| 342 | - private function getUncaughtProcess(){
|
|
| 341 | + private function getUncaughtProcess() {
|
|
| 343 | 342 | |
| 344 | 343 | // catch exception via preg match |
| 345 | 344 | // and then clear the Uncaught statement from inside. |
| 346 | - if(preg_match('@(.*?):@is',$this->data['errStrReal'],$errArr)){
|
|
| 345 | + if (preg_match('@(.*?):@is', $this->data['errStrReal'], $errArr)) {
|
|
| 347 | 346 | |
| 348 | - $this->data['errType']=trim(str_replace('Uncaught','',$errArr[1]));
|
|
| 349 | - $this->data['errorClassNamespace']=$this->data['errType']; |
|
| 347 | + $this->data['errType'] = trim(str_replace('Uncaught', '', $errArr[1]));
|
|
| 348 | + $this->data['errorClassNamespace'] = $this->data['errType']; |
|
| 350 | 349 | } |
| 351 | 350 | |
| 352 | - if(preg_match('@Uncaught@is',$this->data['errStrReal'])
|
|
| 353 | - && preg_match('@(.*?):(.*?)\sin\s@is',$this->data['errStrReal'],$errStrRealArray)){
|
|
| 354 | - $this->data['errStrReal']=trim($errStrRealArray[2]); |
|
| 351 | + if (preg_match('@Uncaught@is', $this->data['errStrReal'])
|
|
| 352 | + && preg_match('@(.*?):(.*?)\sin\s@is', $this->data['errStrReal'], $errStrRealArray)) {
|
|
| 353 | + $this->data['errStrReal'] = trim($errStrRealArray[2]); |
|
| 355 | 354 | } |
| 356 | 355 | |
| 357 | - if($this->data['errType']==="Undefined"){
|
|
| 358 | - $this->data['errStrReal']=$this->data['errStrReal']; |
|
| 356 | + if ($this->data['errType']==="Undefined") {
|
|
| 357 | + $this->data['errStrReal'] = $this->data['errStrReal']; |
|
| 359 | 358 | } |
| 360 | - else{
|
|
| 361 | - $this->data['errContext']['trace']=$this->data['errStrReal']; |
|
| 359 | + else {
|
|
| 360 | + $this->data['errContext']['trace'] = $this->data['errStrReal']; |
|
| 362 | 361 | } |
| 363 | 362 | } |
| 364 | 363 | |
@@ -9,89 +9,89 @@ |
||
| 9 | 9 | /** |
| 10 | 10 | * @var array |
| 11 | 11 | */ |
| 12 | - protected $data=[]; |
|
| 12 | + protected $data = []; |
|
| 13 | 13 | |
| 14 | 14 | /** |
| 15 | 15 | * @param null $msg |
| 16 | 16 | */ |
| 17 | - public function invalidArgument($msg=null){
|
|
| 17 | + public function invalidArgument($msg = null) {
|
|
| 18 | 18 | throw new \InvalidArgumentException($msg); |
| 19 | 19 | } |
| 20 | 20 | |
| 21 | 21 | /** |
| 22 | 22 | * @param null $msg |
| 23 | 23 | */ |
| 24 | - public function badFunctionCall($msg=null){
|
|
| 24 | + public function badFunctionCall($msg = null) {
|
|
| 25 | 25 | throw new \BadFunctionCallException($msg); |
| 26 | 26 | } |
| 27 | 27 | |
| 28 | 28 | /** |
| 29 | 29 | * @param null $msg |
| 30 | 30 | */ |
| 31 | - public function badMethodCall($msg=null){
|
|
| 31 | + public function badMethodCall($msg = null) {
|
|
| 32 | 32 | throw new \BadMethodCallException($msg); |
| 33 | 33 | } |
| 34 | 34 | |
| 35 | 35 | /** |
| 36 | 36 | * @param null $msg |
| 37 | 37 | */ |
| 38 | - public function domain($msg=null){
|
|
| 38 | + public function domain($msg = null) {
|
|
| 39 | 39 | throw new \DomainException($msg); |
| 40 | 40 | } |
| 41 | 41 | |
| 42 | 42 | /** |
| 43 | 43 | * @param null $msg |
| 44 | 44 | */ |
| 45 | - public function length($msg=null){
|
|
| 45 | + public function length($msg = null) {
|
|
| 46 | 46 | throw new \LengthException($msg); |
| 47 | 47 | } |
| 48 | 48 | |
| 49 | 49 | /** |
| 50 | 50 | * @param null $msg |
| 51 | 51 | */ |
| 52 | - public function logic($msg=null){
|
|
| 52 | + public function logic($msg = null) {
|
|
| 53 | 53 | throw new \LogicException($msg); |
| 54 | 54 | } |
| 55 | 55 | |
| 56 | 56 | /** |
| 57 | 57 | * @param null $msg |
| 58 | 58 | */ |
| 59 | - public function outOfRange($msg=null){
|
|
| 59 | + public function outOfRange($msg = null) {
|
|
| 60 | 60 | throw new \OutOfRangeException($msg); |
| 61 | 61 | } |
| 62 | 62 | |
| 63 | 63 | /** |
| 64 | 64 | * @param null $msg |
| 65 | 65 | */ |
| 66 | - public function overflow($msg=null){
|
|
| 66 | + public function overflow($msg = null) {
|
|
| 67 | 67 | throw new \OverflowException($msg); |
| 68 | 68 | } |
| 69 | 69 | |
| 70 | 70 | /** |
| 71 | 71 | * @param null $msg |
| 72 | 72 | */ |
| 73 | - public function range($msg=null){
|
|
| 73 | + public function range($msg = null) {
|
|
| 74 | 74 | throw new \RangeException($msg); |
| 75 | 75 | } |
| 76 | 76 | |
| 77 | 77 | /** |
| 78 | 78 | * @param null $msg |
| 79 | 79 | */ |
| 80 | - public function runtime($msg=null){
|
|
| 80 | + public function runtime($msg = null) {
|
|
| 81 | 81 | throw new \RuntimeException($msg); |
| 82 | 82 | } |
| 83 | 83 | |
| 84 | 84 | /** |
| 85 | 85 | * @param null $msg |
| 86 | 86 | */ |
| 87 | - public function underflow($msg=null){
|
|
| 87 | + public function underflow($msg = null) {
|
|
| 88 | 88 | throw new \UnderflowException($msg); |
| 89 | 89 | } |
| 90 | 90 | |
| 91 | 91 | /** |
| 92 | 92 | * @param null $msg |
| 93 | 93 | */ |
| 94 | - public function unexpectedValue($msg=null){
|
|
| 94 | + public function unexpectedValue($msg = null) {
|
|
| 95 | 95 | throw new \UnexpectedValueException($msg); |
| 96 | 96 | } |
| 97 | 97 | } |
| 98 | 98 | \ No newline at end of file |
@@ -14,13 +14,13 @@ discard block |
||
| 14 | 14 | * @param null $name |
| 15 | 15 | * @param array $params |
| 16 | 16 | */ |
| 17 | - public function __construct($app,$name=null,$params=array()) |
|
| 17 | + public function __construct($app, $name = null, $params = array()) |
|
| 18 | 18 | {
|
| 19 | 19 | parent::__construct($app); |
| 20 | 20 | |
| 21 | 21 | // we help the user to pull a special message from |
| 22 | 22 | // the translate section to be specified by the user for the exception. |
| 23 | - $this->exceptionTranslate($name,$params); |
|
| 23 | + $this->exceptionTranslate($name, $params); |
|
| 24 | 24 | |
| 25 | 25 | // for real file path with |
| 26 | 26 | // debug backtrace method are doing follow. |
@@ -33,13 +33,13 @@ discard block |
||
| 33 | 33 | * @param $name |
| 34 | 34 | * @param array $params |
| 35 | 35 | */ |
| 36 | - private function exceptionTranslate($name,$params=array()) |
|
| 36 | + private function exceptionTranslate($name, $params = array()) |
|
| 37 | 37 | {
|
| 38 | - if($name!==null){
|
|
| 39 | - if(count($params)){
|
|
| 40 | - $this->app->register('exceptionTranslateParams',$name,$params);
|
|
| 38 | + if ($name!==null) {
|
|
| 39 | + if (count($params)) {
|
|
| 40 | + $this->app->register('exceptionTranslateParams', $name, $params);
|
|
| 41 | 41 | } |
| 42 | - $this->app->register('exceptionTranslate',$name);
|
|
| 42 | + $this->app->register('exceptionTranslate', $name);
|
|
| 43 | 43 | } |
| 44 | 44 | } |
| 45 | 45 | |
@@ -50,23 +50,23 @@ discard block |
||
| 50 | 50 | */ |
| 51 | 51 | public function debugBackTrace() |
| 52 | 52 | {
|
| 53 | - foreach (debug_backtrace() as $key=>$value){
|
|
| 53 | + foreach (debug_backtrace() as $key=>$value) {
|
|
| 54 | 54 | |
| 55 | - if(isset(debug_backtrace()[$key],debug_backtrace()[$key]['file'])) |
|
| 55 | + if (isset(debug_backtrace()[$key], debug_backtrace()[$key]['file'])) |
|
| 56 | 56 | {
|
| 57 | - $this->app->register('exceptionFile',debug_backtrace()[$key]['file']);
|
|
| 58 | - $this->app->register('exceptionLine',debug_backtrace()[$key]['line']);
|
|
| 57 | + $this->app->register('exceptionFile', debug_backtrace()[$key]['file']);
|
|
| 58 | + $this->app->register('exceptionLine', debug_backtrace()[$key]['line']);
|
|
| 59 | 59 | } |
| 60 | 60 | |
| 61 | 61 | Dependencies::loadBootstrapperNeedsForException(); |
| 62 | 62 | |
| 63 | - if(isset($value['file']) && isset(core()->urlComponent)){
|
|
| 64 | - if(preg_match('@'.core()->urlComponent['project'].'|boot|providers@',$value['file'])){
|
|
| 63 | + if (isset($value['file']) && isset(core()->urlComponent)) {
|
|
| 64 | + if (preg_match('@'.core()->urlComponent['project'].'|boot|providers@', $value['file'])) {
|
|
| 65 | 65 | |
| 66 | 66 | $this->app->terminate('exceptionFile');
|
| 67 | 67 | $this->app->terminate('exceptionLine');
|
| 68 | - $this->app->register('exceptionFile',$value['file']);
|
|
| 69 | - $this->app->register('exceptionLine',$value['line']);
|
|
| 68 | + $this->app->register('exceptionFile', $value['file']);
|
|
| 69 | + $this->app->register('exceptionLine', $value['line']);
|
|
| 70 | 70 | |
| 71 | 71 | break; |
| 72 | 72 | } |
@@ -96,11 +96,11 @@ discard block |
||
| 96 | 96 | |
| 97 | 97 | |
| 98 | 98 | // we register the custom exception trace value with the global kernel object. |
| 99 | - $this->app->register('exceptiontrace',$customExceptionTrace);
|
|
| 99 | + $this->app->register('exceptiontrace', $customExceptionTrace);
|
|
| 100 | 100 | |
| 101 | 101 | //If the developer wants to execute an event when calling a special exception, |
| 102 | 102 | //we process the event method. |
| 103 | - if(method_exists($callNamespace,'event')){
|
|
| 103 | + if (method_exists($callNamespace, 'event')) {
|
|
| 104 | 104 | $callNamespace->event($customExceptionTrace); |
| 105 | 105 | } |
| 106 | 106 | |
@@ -19,14 +19,14 @@ discard block |
||
| 19 | 19 | * @param $concrete |
| 20 | 20 | * @return mixed|void |
| 21 | 21 | */ |
| 22 | - public function addListener($eventName, $abstract,$concrete) |
|
| 22 | + public function addListener($eventName, $abstract, $concrete) |
|
| 23 | 23 | {
|
| 24 | - if(!isset($this->events[$eventName][strtolower($abstract)])){
|
|
| 24 | + if (!isset($this->events[$eventName][strtolower($abstract)])) {
|
|
| 25 | 25 | |
| 26 | 26 | $this->events[$eventName][strtolower($abstract)] = $concrete; |
| 27 | 27 | |
| 28 | 28 | //we save to kernel object value of the event-dispatcher |
| 29 | - $this->app->register('events',$eventName,$this->events[$eventName]);
|
|
| 29 | + $this->app->register('events', $eventName, $this->events[$eventName]);
|
|
| 30 | 30 | } |
| 31 | 31 | } |
| 32 | 32 | |
@@ -34,13 +34,13 @@ discard block |
||
| 34 | 34 | * @param array $subscriber |
| 35 | 35 | * @return mixed|void |
| 36 | 36 | */ |
| 37 | - public function addSubscriber($subscriber=array()) |
|
| 37 | + public function addSubscriber($subscriber = array()) |
|
| 38 | 38 | {
|
| 39 | 39 | // To take advantage of an existing event, |
| 40 | 40 | // you need to connect a listener to the dispatcher |
| 41 | 41 | // so that it can be notified when the event is dispatched. |
| 42 | 42 | // A call to the dispatcher's addListener() method associates any valid PHP callable to an event: |
| 43 | - $this->listen = array_merge($this->getListeners(),[$this->event=>['subscriber'=>$subscriber]]); |
|
| 43 | + $this->listen = array_merge($this->getListeners(), [$this->event=>['subscriber'=>$subscriber]]); |
|
| 44 | 44 | } |
| 45 | 45 | } |
| 46 | 46 | |