Skip to content
This repository has been archived by the owner on Jan 2, 2023. It is now read-only.

Commit

Permalink
Merge pull request #92 from vinkla/docblocs
Browse files Browse the repository at this point in the history
Update docblocs
  • Loading branch information
tobyzerner committed May 26, 2016
2 parents 7cb11ec + 3035ee5 commit 0feda5d
Show file tree
Hide file tree
Showing 15 changed files with 93 additions and 34 deletions.
3 changes: 2 additions & 1 deletion src/AbstractSerializer.php
Expand Up @@ -65,7 +65,7 @@ public function getMeta($model)
/**
* {@inheritdoc}
*
* @throws LogicException
* @throws \LogicException
*/
public function getRelationship($model, $name)
{
Expand All @@ -88,6 +88,7 @@ public function getRelationship($model, $name)
* kebab-case is converted into camelCase.
*
* @param string $name
*
* @return string
*/
private function getRelationshipMethodName($name)
Expand Down
10 changes: 8 additions & 2 deletions src/Collection.php
Expand Up @@ -22,7 +22,7 @@ class Collection implements ElementInterface
* Create a new collection instance.
*
* @param mixed $data
* @param SerializerInterface $serializer
* @param \Tobscure\JsonApi\SerializerInterface $serializer
*/
public function __construct($data, SerializerInterface $serializer)
{
Expand All @@ -34,7 +34,8 @@ public function __construct($data, SerializerInterface $serializer)
*
* @param mixed $data
* @param SerializerInterface $serializer
* @return Resource[]
*
* @return \Tobscure\JsonApi\Resource[]
*/
protected function buildResources($data, SerializerInterface $serializer)
{
Expand Down Expand Up @@ -63,6 +64,8 @@ public function getResources()
* Set the resources array.
*
* @param array $resources
*
* @return void
*/
public function setResources($resources)
{
Expand All @@ -73,6 +76,7 @@ public function setResources($resources)
* Request a relationship to be included for all resources.
*
* @param string|array $relationships
*
* @return $this
*/
public function with($relationships)
Expand All @@ -88,6 +92,7 @@ public function with($relationships)
* Request a relationship to be identified for all resources.
*
* @param string|array $relationships
*
* @return $this
*/
public function identify($relationships)
Expand All @@ -103,6 +108,7 @@ public function identify($relationships)
* Request a restricted set of fields.
*
* @param array|null $fields
*
* @return $this
*/
public function fields($fields)
Expand Down
17 changes: 11 additions & 6 deletions src/Document.php
Expand Up @@ -57,9 +57,10 @@ public function __construct(ElementInterface $data = null)
/**
* Get included resources.
*
* @param ElementInterface $element
* @param \Tobscure\JsonApi\ElementInterface $element
* @param bool $includeParent
* @return Resource[]
*
* @return \Tobscure\JsonApi\Resource[]
*/
protected function getIncluded(ElementInterface $element, $includeParent = false)
{
Expand Down Expand Up @@ -107,9 +108,10 @@ protected function getIncluded(ElementInterface $element, $includeParent = false
}

/**
* @param Resource[] $resources
* @param Resource $newResource
* @return Resource[]
* @param \Tobscure\JsonApi\Resource[] $resources
* @param \Tobscure\JsonApi\Resource $newResource
*
* @return \Tobscure\JsonApi\Resource[]
*/
protected function mergeResource(array $resources, Resource $newResource)
{
Expand All @@ -128,7 +130,8 @@ protected function mergeResource(array $resources, Resource $newResource)
/**
* Set the data object.
*
* @param ElementInterface $element
* @param \Tobscure\JsonApi\ElementInterface $element
*
* @return $this
*/
public function setData(ElementInterface $element)
Expand All @@ -142,6 +145,7 @@ public function setData(ElementInterface $element)
* Set the errors array.
*
* @param array $errors
*
* @return $this
*/
public function setErrors($errors)
Expand All @@ -155,6 +159,7 @@ public function setErrors($errors)
* Set the jsonapi array.
*
* @param array $jsonapi
*
* @return $this
*/
public function setJsonapi($jsonapi)
Expand Down
2 changes: 2 additions & 0 deletions src/ElementInterface.php
Expand Up @@ -38,6 +38,7 @@ public function toIdentifier();
* Request a relationship to be included.
*
* @param string|array $relationships
*
* @return $this
*/
public function with($relationships);
Expand All @@ -46,6 +47,7 @@ public function with($relationships);
* Request a restricted set of fields.
*
* @param array|null $fields
*
* @return $this
*/
public function fields($fields);
Expand Down
10 changes: 7 additions & 3 deletions src/ErrorHandler.php
Expand Up @@ -20,16 +20,18 @@ class ErrorHandler
/**
* Stores the valid handlers.
*
* @var ExceptionHandlerInterface[]
* @var \Tobscure\JsonApi\Exception\Handler\ExceptionHandlerInterface[]
*/
private $handlers = [];

/**
* Handle the exception provided.
*
* @param Exception $e
* @return \Tobscure\JsonApi\Exception\Handler\ResponseBag
*
* @throws RuntimeException
*
* @return \Tobscure\JsonApi\Exception\Handler\ResponseBag
*/
public function handle(Exception $e)
{
Expand All @@ -45,7 +47,9 @@ public function handle(Exception $e)
/**
* Register a new exception handler.
*
* @param ExceptionHandlerInterface $handler
* @param \Tobscure\JsonApi\Exception\Handler\ExceptionHandlerInterface $handler
*
* @return void
*/
public function registerHandler(ExceptionHandlerInterface $handler)
{
Expand Down
8 changes: 5 additions & 3 deletions src/Exception/Handler/ExceptionHandlerInterface.php
Expand Up @@ -19,16 +19,18 @@ interface ExceptionHandlerInterface
* If the exception handler is able to format a response for the provided exception,
* then the implementation should return true.
*
* @param Exception $e
* @param \Exception $e
*
* @return bool
*/
public function manages(Exception $e);

/**
* Handle the provided exception.
*
* @param Exception $e
* @return ResponseBag
* @param \Exception $e
*
* @return \Tobscure\JsonApi\Exception\Handler\ResponseBag
*/
public function handle(Exception $e);
}
3 changes: 2 additions & 1 deletion src/Exception/Handler/FallbackExceptionHandler.php
Expand Up @@ -48,8 +48,9 @@ public function handle(Exception $e)
}

/**
* @param Exception $e
* @param \Exception $e
* @param $status
*
* @return array
*/
private function constructError(Exception $e, $status)
Expand Down
1 change: 1 addition & 0 deletions src/Exception/InvalidParameterException.php
Expand Up @@ -15,4 +15,5 @@

class InvalidParameterException extends Exception
{
//
}
6 changes: 6 additions & 0 deletions src/LinksTrait.php
Expand Up @@ -34,6 +34,7 @@ public function getLinks()
* Set the links.
*
* @param array $links
*
* @return $this
*/
public function setLinks(array $links)
Expand All @@ -48,6 +49,7 @@ public function setLinks(array $links)
*
* @param string $key
* @param string $value
*
* @return $this
*/
public function addLink($key, $value)
Expand All @@ -65,6 +67,8 @@ public function addLink($key, $value)
* @param int $offset The current offset.
* @param int $limit The current limit.
* @param int|null $total The total number of results, or null if unknown.
*
* @return void
*/
public function addPaginationLinks($url, array $queryParams, $offset, $limit, $total = null)
{
Expand Down Expand Up @@ -95,6 +99,8 @@ public function addPaginationLinks($url, array $queryParams, $offset, $limit, $t
* @param array $queryParams The query params provided in the request.
* @param int $offset The offset to link to.
* @param int $limit The current limit.
*
* @return void
*/
protected function addPaginationLink($name, $url, array $queryParams, $offset, $limit)
{
Expand Down
2 changes: 2 additions & 0 deletions src/MetaTrait.php
Expand Up @@ -34,6 +34,7 @@ public function getMeta()
* Set the meta data array.
*
* @param array $meta
*
* @return $this
*/
public function setMeta(array $meta)
Expand All @@ -48,6 +49,7 @@ public function setMeta(array $meta)
*
* @param string $key
* @param string $value
*
* @return $this
*/
public function addMeta($key, $value)
Expand Down
19 changes: 15 additions & 4 deletions src/Parameters.php
Expand Up @@ -32,8 +32,10 @@ public function __construct(array $input)
* Get the includes.
*
* @param array $available
*
* @throws \Tobscure\JsonApi\Exception\InvalidParameterException
*
* @return array
* @throws InvalidParameterException
*/
public function getInclude(array $available = [])
{
Expand All @@ -56,8 +58,10 @@ public function getInclude(array $available = [])
* Get number of offset.
*
* @param int|null $perPage
*
* @throws \Tobscure\JsonApi\Exception\InvalidParameterException
*
* @return int
* @throws InvalidParameterException
*/
public function getOffset($perPage = null)
{
Expand All @@ -78,8 +82,10 @@ public function getOffset($perPage = null)
* Calculate the offset based on the page[number] parameter.
*
* @param int $perPage
*
* @throws \Tobscure\JsonApi\Exception\InvalidParameterException
*
* @return int
* @throws InvalidParameterException
*/
protected function getOffsetFromNumber($perPage)
{
Expand All @@ -96,6 +102,7 @@ protected function getOffsetFromNumber($perPage)
* Get the limit.
*
* @param int|null $max
*
* @return int|null
*/
public function getLimit($max = null)
Expand All @@ -113,8 +120,10 @@ public function getLimit($max = null)
* Get the sort.
*
* @param array $available
*
* @throws \Tobscure\JsonApi\Exception\InvalidParameterException
*
* @return array
* @throws InvalidParameterException
*/
public function getSort(array $available = [])
{
Expand Down Expand Up @@ -177,6 +186,7 @@ public function getFilter()
*
* @param string $key
* @param null $default
*
* @return mixed
*/
protected function getInput($key, $default = null)
Expand All @@ -188,6 +198,7 @@ protected function getInput($key, $default = null)
* Get the page.
*
* @param string $key
*
* @return string
*/
protected function getPage($key)
Expand Down
9 changes: 5 additions & 4 deletions src/Relationship.php
Expand Up @@ -19,14 +19,14 @@ class Relationship
/**
* The data object.
*
* @var ElementInterface|null
* @var \Tobscure\JsonApi\ElementInterface|null
*/
protected $data;

/**
* Create a new relationship.
*
* @param ElementInterface|null $data
* @param \Tobscure\JsonApi\ElementInterface|null $data
*/
public function __construct(ElementInterface $data = null)
{
Expand All @@ -36,7 +36,7 @@ public function __construct(ElementInterface $data = null)
/**
* Get the data object.
*
* @return ElementInterface|null
* @return \Tobscure\JsonApi\ElementInterface|null
*/
public function getData()
{
Expand All @@ -46,7 +46,8 @@ public function getData()
/**
* Set the data object.
*
* @param ElementInterface|null $data
* @param \Tobscure\JsonApi\ElementInterface|null $data
*
* @return $this
*/
public function setData($data)
Expand Down

0 comments on commit 0feda5d

Please sign in to comment.