Skip to content

Commit

Permalink
Fixed code style and added provider to composer.json (laravel 5.5)
Browse files Browse the repository at this point in the history
  • Loading branch information
Samuel Martins committed Sep 2, 2017
1 parent 1349e18 commit 0f7341e
Show file tree
Hide file tree
Showing 8 changed files with 19 additions and 12 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ Install the package
$ composer require sfelix-martins/json-exception-handler
```

Add the `JsonHandlerServiceProvider` to your `config/app.php` providers array:
If you are not using **Laravel 5.5** version add the `JsonHandlerServiceProvider` to your `config/app.php` providers array:

```php
'providers' => [
Expand Down
7 changes: 7 additions & 0 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,5 +17,12 @@
"psr-4": {
"SMartins\\JsonHandler\\": "src/"
}
},
"extra": {
"laravel": {
"providers": [
"SMartins\\JsonHandler\\JsonHandlerServiceProvider"
]
}
}
}
2 changes: 1 addition & 1 deletion src/AuthorizationHandler.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,4 +16,4 @@ public function authorizationException(AuthorizationException $exception)

return $this->response = $response;
}
}
}
10 changes: 5 additions & 5 deletions src/JsonHandler.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,17 +33,17 @@ public function jsonResponse(Exception $exception)
{
$this->setDefaultResponse($exception);

if ($exception instanceOf ValidationException) {
if ($exception instanceof ValidationException) {
$this->validationException($exception);
} elseif ($exception instanceOf ModelNotFoundException) {
} elseif ($exception instanceof ModelNotFoundException) {
$this->modelNotFoundException($exception);
} elseif ($exception instanceOf AuthorizationException) {
} elseif ($exception instanceof AuthorizationException) {
$this->authorizationException($exception);
}

return response()->json(
$this->response->toArray(),
$this->response->toArray(),
$this->response->getHttpCode()
);
}
}
}
2 changes: 1 addition & 1 deletion src/ModelNotFoundHandler.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,4 +26,4 @@ public function extractEntitieName($model)
$entitieName = explode('\\', $model);
return end($entitieName);
}
}
}
2 changes: 1 addition & 1 deletion src/Responses/Response.php
Original file line number Diff line number Diff line change
Expand Up @@ -79,4 +79,4 @@ public function toArray()

return $response;
}
}
}
2 changes: 1 addition & 1 deletion src/ValidationHandler.php
Original file line number Diff line number Diff line change
Expand Up @@ -60,4 +60,4 @@ public function formatErrorMessages($messages)

return $errors;
}
}
}
4 changes: 2 additions & 2 deletions src/config/json-exception-handler.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,6 @@
| The http code value to not managed exceptions. Generally the code used is
| 500 - Internal Server Error.
*/
'http_code' => 500,
'http_code' => 500,

];
];

0 comments on commit 0f7341e

Please sign in to comment.