Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions src/EchoIt/JsonApi/ErrorResponse.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ class ErrorResponse extends JsonResponse
* @param int $httpStatusCode HTTP status code
* @param mixed $errorCode Internal error code
* @param string $errorTitle Error description
* @param array $additionalAttrs
*/
public function __construct($httpStatusCode, $errorCode, $errorTitle, array $additionalAttrs = array())
{
Expand Down
3 changes: 2 additions & 1 deletion src/EchoIt/JsonApi/Exception.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ class Exception extends \Exception
* @param string $message The Exception message to throw
* @param int $code The Exception code
* @param int $httpStatusCode HTTP status code which can be used for broken request
* @param array $additionalAttrs
*/
public function __construct($message = '', $code = 0, $httpStatusCode = 500, array $additionalAttrs = array())
{
Expand All @@ -28,7 +29,7 @@ public function __construct($message = '', $code = 0, $httpStatusCode = 500, arr
/**
* This method returns a HTTP response representation of the Exception
*
* @return JsonApi\ErrorResponse
* @return \EchoIt\JsonApi\ErrorResponse
*/
public function response()
{
Expand Down
10 changes: 5 additions & 5 deletions src/EchoIt/JsonApi/Exception/Validation.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,10 @@ class Validation extends Exception
/**
* Constructor.
*
* @param string $message The Exception message to throw
* @param int $code The Exception code
* @param int $httpStatusCode HTTP status code which can be used for broken request
* @param Illuminate\Support\MessageBag $messages Validation errors
* @param string $message The Exception message to throw
* @param int $code The Exception code
* @param int $httpStatusCode HTTP status code which can be used for broken request
* @param \Illuminate\Support\MessageBag $messages Validation errors
*/
public function __construct($message = '', $code = 0, $httpStatusCode = 500, ValidationMessages $messages = NULL)
{
Expand All @@ -33,7 +33,7 @@ public function __construct($message = '', $code = 0, $httpStatusCode = 500, Val
/**
* This method returns a HTTP response representation of the Exception
*
* @return JsonApi\MultiErrorResponse
* @return \EchoIt\JsonApi\MultiErrorResponse
*/
public function response()
{
Expand Down
67 changes: 38 additions & 29 deletions src/EchoIt/JsonApi/Handler.php
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ abstract class Handler
/**
* Constructor.
*
* @param JsonApi\Request $request
* @param \EchoIt\JsonApi\Request $request
*/
public function __construct(Request $request)
{
Expand All @@ -57,7 +57,8 @@ public function supportsMethod($method)
/**
* Fulfill the API request and return a response.
*
* @return JsonApi\Response
* @return \EchoIT\JsonApi\Response
* @throws Exception
*/
public function fulfillRequest()
{
Expand Down Expand Up @@ -135,6 +136,7 @@ protected function loadRelatedModels(Model $model) {
/**
* Returns which requested resources are available to include.
*
* @param Model $model
* @return array
*/
protected function exposedRelationsFromRequest($model = null)
Expand Down Expand Up @@ -174,7 +176,7 @@ protected function unknownRelationsFromRequest()
/**
* Iterate through result set to fetch the requested resources to include.
*
* @param Illuminate\Database\Eloquent\Collection|JsonApi\Model $models
* @param \Illuminate\Database\Eloquent\Collection|\EchoIT\JsonApi\Model $models
* @return array
*/
protected function getIncludedModels($models)
Expand Down Expand Up @@ -315,9 +317,10 @@ protected static function methodHandlerName($method)
/**
* Returns the models from a relationship. Will always return as array.
*
* @param Illuminate\Database\Eloquent\Model $model
* @param \Illuminate\Database\Eloquent\Model $model
* @param string $relationKey
* @return array|Illuminate\Database\Eloquent\Collection
* @return array|\Illuminate\Database\Eloquent\Collection
* @throws Exception
*/
protected static function getModelsForRelation($model, $relationKey)
{
Expand Down Expand Up @@ -346,7 +349,7 @@ protected static function getModelsForRelation($model, $relationKey)
*
* @param array &$array
* @param string $key
* @return Illuminate\Database\Eloquent\Collection
* @return \Illuminate\Database\Eloquent\Collection
*/
protected static function getCollectionOrCreate(&$array, $key)
{
Expand Down Expand Up @@ -374,8 +377,9 @@ protected static function getModelNameForRelation($relationName)
* Function to handle sorting requests.
*
* @param array $cols list of column names to sort on
* @param EchoIt\JsonApi\Model $model
* @return EchoIt\JsonApi\Model
* @param \EchoIt\JsonApi\Model $model
* @return \EchoIt\JsonApi\Model
* @throws Exception
*/
protected function handleSortRequest($cols, $model)
{
Expand Down Expand Up @@ -404,6 +408,7 @@ protected function handleSortRequest($cols, $model)
* @param string $content
* @param string $type the type the content is expected to be.
* @return array
* @throws Exception
*/
protected function parseRequestContent($content, $type)
{
Expand Down Expand Up @@ -439,10 +444,10 @@ protected function parseRequestContent($content, $type)
/**
* Function to handle pagination requests.
*
* @param EchoIt\JsonApi\Request $request
* @param EchoIt\JsonApi\Model $model
* @param \EchoIt\JsonApi\Request $request
* @param \EchoIt\JsonApi\Model $model
* @param integer $total the total number of records
* @return Illuminate\Pagination\LengthAwarePaginator
* @return \Illuminate\Pagination\LengthAwarePaginator
*/
protected function handlePaginationRequest($request, $model, $total = null)
{
Expand Down Expand Up @@ -473,8 +478,8 @@ protected function handlePaginationRequest($request, $model, $total = null)
* Function to handle filtering requests.
*
* @param array $filters key=>value pairs of column and value to filter on
* @param EchoIt\JsonApi\Model $model
* @return EchoIt\JsonApi\Model
* @param \EchoIt\JsonApi\Model $model
* @return \EchoIt\JsonApi\Model
*/
protected function handleFilterRequest($filters, $model)
{
Expand All @@ -488,9 +493,10 @@ protected function handleFilterRequest($filters, $model)
* Default handling of GET request.
* Must be called explicitly in handleGet function.
*
* @param EchoIt\JsonApi\Request $request
* @param EchoIt\JsonApi\Model $model
* @return EchoIt\JsonApi\Model|Illuminate\Pagination\LengthAwarePaginator
* @param \EchoIt\JsonApi\Request $request
* @param \EchoIt\JsonApi\Model $model
* @return \EchoIt\JsonApi\Model|\Illuminate\Pagination\LengthAwarePaginator
* @throws Exception
*/
protected function handleGetDefault(Request $request, $model)
{
Expand Down Expand Up @@ -531,12 +537,12 @@ protected function handleGetDefault(Request $request, $model)
* Validates passed data against a model
* Validation performed safely and only if model provides rules
*
* @param EchoIt\JsonApi\Model $model model to validate against
* @param Array $values passed array of values
* @param \EchoIt\JsonApi\Model $model model to validate against
* @param Array $values passed array of values
*
* @throws Exception\Validation Exception thrown when validation fails
* @throws Exception\Validation Exception thrown when validation fails
*
* @return Bool true if validation successful
* @return Bool true if validation successful
*/
protected function validateModelData(Model $model, Array $values)
{
Expand All @@ -558,9 +564,10 @@ protected function validateModelData(Model $model, Array $values)
* Default handling of POST request.
* Must be called explicitly in handlePost function.
*
* @param EchoIt\JsonApi\Request $request
* @param EchoIt\JsonApi\Model $model
* @return EchoIt\JsonApi\Model
* @param \EchoIt\JsonApi\Request $request
* @param \EchoIt\JsonApi\Model $model
* @return \EchoIt\JsonApi\Model
* @throws Exception
*/
public function handlePostDefault(Request $request, $model)
{
Expand All @@ -584,9 +591,10 @@ public function handlePostDefault(Request $request, $model)
* Default handling of PUT request.
* Must be called explicitly in handlePut function.
*
* @param EchoIt\JsonApi\Request $request
* @param EchoIt\JsonApi\Model $model
* @return EchoIt\JsonApi\Model
* @param \EchoIt\JsonApi\Request $request
* @param \EchoIt\JsonApi\Model $model
* @return \EchoIt\JsonApi\Model
* @throws Exception
*/
public function handlePutDefault(Request $request, $model)
{
Expand Down Expand Up @@ -639,9 +647,10 @@ public function handlePutDefault(Request $request, $model)
* Default handling of DELETE request.
* Must be called explicitly in handleDelete function.
*
* @param EchoIt\JsonApi\Request $request
* @param EchoIt\JsonApi\Model $model
* @return EchoIt\JsonApi\Model
* @param \EchoIt\JsonApi\Request $request
* @param \EchoIt\JsonApi\Model $model
* @return \EchoIt\JsonApi\Model
* @throws Exception
*/
public function handleDeleteDefault(Request $request, $model)
{
Expand Down
5 changes: 3 additions & 2 deletions src/EchoIt/JsonApi/Model.php
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,8 @@ public function relationsFromMethod() {
/**
* mark this model as changed
*
* @return bool
* @param bool $changed
* @return void
*/
public function markChanged($changed = true)
{
Expand Down Expand Up @@ -127,7 +128,7 @@ public function getResourceType()
*
* @param Array $values user passed values (request data)
*
* @return bool|Illuminate\Support\MessageBag True on pass, MessageBag of errors on fail
* @return bool|\Illuminate\Support\MessageBag True on pass, MessageBag of errors on fail
*/
public function validateArray(Array $values)
{
Expand Down
8 changes: 4 additions & 4 deletions src/EchoIt/JsonApi/MultiErrorResponse.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,10 @@ class MultiErrorResponse extends JsonResponse
/**
* Constructor.
*
* @param int $httpStatusCode HTTP status code
* @param mixed $errorCode Internal error code
* @param string $errorTitle Error description
* @param Illuminate\Support\MessageBag $errors Validation errors
* @param int $httpStatusCode HTTP status code
* @param mixed $errorCode Internal error code
* @param string $errorTitle Error description
* @param \Illuminate\Support\MessageBag $errors Validation errors
*/
public function __construct($httpStatusCode, $errorCode, $errorTitle, ValidationMessages $errors = NULL)
{
Expand Down
3 changes: 2 additions & 1 deletion src/EchoIt/JsonApi/Response.php
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ class Response
* Constructor
*
* @param array|object $body
* @param int $httpStatusCode
*/
public function __construct($body, $httpStatusCode = 200)
{
Expand All @@ -60,7 +61,7 @@ public function __set($key, $value)
* Returns a JsonResponse with the set parameters and body.
*
* @param string $bodyKey The key on which to set the main response.
* @return Illuminate\Http\JsonResponse
* @return \Illuminate\Http\JsonResponse
*/
public function toJsonResponse($bodyKey = 'data', $options = 0)
{
Expand Down