@@ -20,19 +20,19 @@ discard block |
||
| 20 | 20 | * @param bool $return |
| 21 | 21 | * @return mixed|void |
| 22 | 22 | */ |
| 23 | - private function fireEvent($event=null,$return=false) |
|
| 23 | + private function fireEvent($event = null, $return = false) |
|
| 24 | 24 | {
|
| 25 | 25 | // if an array of response-events is registered |
| 26 | 26 | // in the container system, the event will fire. |
| 27 | - if($this->app->has('response-event.'.$event)){
|
|
| 27 | + if ($this->app->has('response-event.'.$event)) {
|
|
| 28 | 28 | $event = $this->app->get('response-event.'.$event);
|
| 29 | 29 | |
| 30 | 30 | // the event to be fired must be |
| 31 | 31 | // a closure instance. |
| 32 | - if($event instanceof Closure){
|
|
| 32 | + if ($event instanceof Closure) {
|
|
| 33 | 33 | $eventResolved = $event($this->app); |
| 34 | 34 | |
| 35 | - if($return){
|
|
| 35 | + if ($return) {
|
|
| 36 | 36 | return $eventResolved; |
| 37 | 37 | } |
| 38 | 38 | } |
@@ -49,16 +49,16 @@ discard block |
||
| 49 | 49 | */ |
| 50 | 50 | private function callController() |
| 51 | 51 | {
|
| 52 | - $this->fireEvent('before',true);
|
|
| 52 | + $this->fireEvent('before', true);
|
|
| 53 | 53 | |
| 54 | - if($this->app->has('output')){
|
|
| 54 | + if ($this->app->has('output')) {
|
|
| 55 | 55 | return $this->app->get('output');
|
| 56 | 56 | } |
| 57 | 57 | |
| 58 | - if(is_array($event = $this->fireEvent('output',true))){
|
|
| 58 | + if (is_array($event = $this->fireEvent('output', true))) {
|
|
| 59 | 59 | $controller = $event; |
| 60 | 60 | } |
| 61 | - else{
|
|
| 61 | + else {
|
|
| 62 | 62 | |
| 63 | 63 | //the singleton eager class is a class built to temporarily prevent |
| 64 | 64 | //the use of user-side kernel objects used by the rest system. |
@@ -69,7 +69,7 @@ discard block |
||
| 69 | 69 | $controller = $this->getCallBindController(); |
| 70 | 70 | } |
| 71 | 71 | |
| 72 | - $this->app->register('output',$controller);
|
|
| 72 | + $this->app->register('output', $controller);
|
|
| 73 | 73 | |
| 74 | 74 | return $controller; |
| 75 | 75 | } |
@@ -82,12 +82,12 @@ discard block |
||
| 82 | 82 | private function getCallBindController() |
| 83 | 83 | {
|
| 84 | 84 | //we finally process the method of the class invoked by the user as a process and prepare it for the response |
| 85 | - return app()->resolve(RouteWatch::class)->watch(function(){
|
|
| 85 | + return app()->resolve(RouteWatch::class)->watch(function() {
|
|
| 86 | 86 | |
| 87 | 87 | // if the method in the instance object exists, |
| 88 | 88 | // this method is executed to produce the output. |
| 89 | - if(method_exists($this->app['instanceController'],$this->app['method'])){
|
|
| 90 | - return $this->app['di']($this->app['instanceController'],$this->app['method']); |
|
| 89 | + if (method_exists($this->app['instanceController'], $this->app['method'])) {
|
|
| 90 | + return $this->app['di']($this->app['instanceController'], $this->app['method']); |
|
| 91 | 91 | } |
| 92 | 92 | |
| 93 | 93 | //throw exception as unsuccessful |
@@ -105,7 +105,7 @@ discard block |
||
| 105 | 105 | */ |
| 106 | 106 | public function handle() |
| 107 | 107 | {
|
| 108 | - $this->app->register('routerResult',$this->callController());
|
|
| 108 | + $this->app->register('routerResult', $this->callController());
|
|
| 109 | 109 | |
| 110 | 110 | //we call our services as controller |
| 111 | 111 | return $this->app['routerResult']; |
@@ -122,8 +122,8 @@ discard block |
||
| 122 | 122 | $namespace = $this->getControllerNamespace(); |
| 123 | 123 | |
| 124 | 124 | //utils make bind via dependency injection named as service container |
| 125 | - $this->app->register('serviceConf',$this->app['fileSystem']->callFile(StaticPathModel::getServiceConf()));
|
|
| 126 | - $this->app->register('instanceController',$this->app->resolve($namespace));
|
|
| 125 | + $this->app->register('serviceConf', $this->app['fileSystem']->callFile(StaticPathModel::getServiceConf()));
|
|
| 126 | + $this->app->register('instanceController', $this->app->resolve($namespace));
|
|
| 127 | 127 | } |
| 128 | 128 | |
| 129 | 129 | /** |
@@ -140,7 +140,7 @@ discard block |
||
| 140 | 140 | |
| 141 | 141 | // based on the serviceConf variable, |
| 142 | 142 | // we are doing parameter bindings in the method context in the routeParameters array key. |
| 143 | - $this->app->register('serviceConf','routeParameters',[$method=>$parameters]);
|
|
| 143 | + $this->app->register('serviceConf', 'routeParameters', [$method=>$parameters]);
|
|
| 144 | 144 | |
| 145 | 145 | } |
| 146 | 146 | |
@@ -152,7 +152,7 @@ discard block |
||
| 152 | 152 | */ |
| 153 | 153 | public function setMethodNameViaDefine($methodName) |
| 154 | 154 | {
|
| 155 | - define('methodName',strtolower($methodName));
|
|
| 155 | + define('methodName', strtolower($methodName));
|
|
| 156 | 156 | } |
| 157 | 157 | |
| 158 | 158 | |
@@ -183,7 +183,7 @@ discard block |
||
| 183 | 183 | $fromRoutes = Route::getRouteResolve(); |
| 184 | 184 | $method = $fromRoutes['method'] ?? $method; |
| 185 | 185 | |
| 186 | - $this->app->register('method',$method);
|
|
| 186 | + $this->app->register('method', $method);
|
|
| 187 | 187 | $this->app->register('routeParameters', $this->routeParametersAssign($this->resolveMethod($method)));
|
| 188 | 188 | |
| 189 | 189 | } |
@@ -28,13 +28,13 @@ discard block |
||
| 28 | 28 | //the auto service to be called. |
| 29 | 29 | return ClosureDispatcher::bind($controllerInstance)->call(function() use($controllerInstance){
|
| 30 | 30 | |
| 31 | - if(property_exists($controllerInstance,'response')){
|
|
| 31 | + if (property_exists($controllerInstance, 'response')) {
|
|
| 32 | 32 | return $controllerInstance->response; |
| 33 | 33 | } |
| 34 | 34 | |
| 35 | 35 | // if the client wishes, |
| 36 | 36 | // data can be returned in the supported format. |
| 37 | - if(app()->has('clientResponseType')){
|
|
| 37 | + if (app()->has('clientResponseType')) {
|
|
| 38 | 38 | return app()->get('clientResponseType');
|
| 39 | 39 | } |
| 40 | 40 | |
@@ -49,19 +49,19 @@ discard block |
||
| 49 | 49 | * @param bool $return |
| 50 | 50 | * @return void |
| 51 | 51 | */ |
| 52 | - protected function fireEvent($event=null,$return=false) |
|
| 52 | + protected function fireEvent($event = null, $return = false) |
|
| 53 | 53 | {
|
| 54 | 54 | // if an array of response-events is registered |
| 55 | 55 | // in the container system, the event will fire. |
| 56 | - if($this->app->has('response-event.'.$event)){
|
|
| 56 | + if ($this->app->has('response-event.'.$event)) {
|
|
| 57 | 57 | $event = $this->app->get('response-event.'.$event);
|
| 58 | 58 | |
| 59 | 59 | // the event to be fired must be |
| 60 | 60 | // a closure instance. |
| 61 | - if($event instanceof Closure){
|
|
| 61 | + if ($event instanceof Closure) {
|
|
| 62 | 62 | $eventResolved = $event($this->app); |
| 63 | 63 | |
| 64 | - if($return){
|
|
| 64 | + if ($return) {
|
|
| 65 | 65 | return $eventResolved; |
| 66 | 66 | } |
| 67 | 67 | } |
@@ -100,8 +100,7 @@ discard block |
||
| 100 | 100 | {
|
| 101 | 101 | //we get the response type by checking the instanceController object from the router. |
| 102 | 102 | //Each type of response is in the base class in project directory. |
| 103 | - return ($this->getControllerInstance()===null) ? core()->responseType : |
|
| 104 | - $this->appResponseType(); |
|
| 103 | + return ($this->getControllerInstance()===null) ? core()->responseType : $this->appResponseType(); |
|
| 105 | 104 | } |
| 106 | 105 | |
| 107 | 106 | /** |
@@ -112,13 +111,13 @@ discard block |
||
| 112 | 111 | public function handle() |
| 113 | 112 | {
|
| 114 | 113 | //definition for singleton instance |
| 115 | - define ('responseApp',true);
|
|
| 114 | + define('responseApp', true);
|
|
| 116 | 115 | |
| 117 | 116 | //get out putter for response |
| 118 | 117 | $formatter = $this->formatter(); |
| 119 | 118 | |
| 120 | 119 | //if out putter is not null |
| 121 | - if(Utils::isNamespaceExists($formatter)){
|
|
| 120 | + if (Utils::isNamespaceExists($formatter)) {
|
|
| 122 | 121 | |
| 123 | 122 | //get outputter for result |
| 124 | 123 | $outPutter = $this->getOutPutter(); |
@@ -127,9 +126,9 @@ discard block |
||
| 127 | 126 | // and run the handle method. |
| 128 | 127 | $result = app()->resolve($formatter)->{$this->getResponseKind()}($outPutter);
|
| 129 | 128 | |
| 130 | - $this->app->register('result',$result);
|
|
| 129 | + $this->app->register('result', $result);
|
|
| 131 | 130 | |
| 132 | - $this->fireEvent('after',true);
|
|
| 131 | + $this->fireEvent('after', true);
|
|
| 133 | 132 | } |
| 134 | 133 | } |
| 135 | 134 | |
@@ -139,7 +138,7 @@ discard block |
||
| 139 | 138 | * @param array $data |
| 140 | 139 | * @return array |
| 141 | 140 | */ |
| 142 | - public function outputFormatter($data=array(),$outputter='json') |
|
| 141 | + public function outputFormatter($data = array(), $outputter = 'json') |
|
| 143 | 142 | {
|
| 144 | 143 | $dataCapsule = config('response.data');
|
| 145 | 144 | |