| @@ -5,7 +5,7 @@ | ||
| 5 | 5 | use alsvanzelf\jsonapi\exceptions\Exception; | 
| 6 | 6 | |
| 7 | 7 |  class DuplicateException extends Exception { | 
| 8 | -	public function __construct($message='', $code=409, $previous=null) { | |
| 8 | +	public function __construct($message = '', $code = 409, $previous = null) { | |
| 9 | 9 | return parent::__construct($message, $code, $previous); | 
| 10 | 10 | } | 
| 11 | 11 | } | 
| @@ -5,7 +5,7 @@ | ||
| 5 | 5 | use alsvanzelf\jsonapi\exceptions\Exception; | 
| 6 | 6 | |
| 7 | 7 |  class InputException extends Exception { | 
| 8 | -	public function __construct($message='', $code=400, $previous=null) { | |
| 8 | +	public function __construct($message = '', $code = 400, $previous = null) { | |
| 9 | 9 | return parent::__construct($message, $code, $previous); | 
| 10 | 10 | } | 
| 11 | 11 | } | 
| @@ -43,7 +43,7 @@ | ||
| 43 | 43 | * @param mixed $value | 
| 44 | 44 | * @param string $level one of the Document::LEVEL_* constants, optional, defaults to Document::LEVEL_ROOT | 
| 45 | 45 | */ | 
| 46 | -	public function add($key, $value, $level=Document::LEVEL_ROOT) { | |
| 46 | +	public function add($key, $value, $level = Document::LEVEL_ROOT) { | |
| 47 | 47 | parent::addMeta($key, $value, $level); | 
| 48 | 48 | } | 
| 49 | 49 | |
| @@ -54,7 +54,7 @@ discard block | ||
| 54 | 54 | * @param string|int $id | 
| 55 | 55 | * @param array $attributes optional, if given a ResourceObject is added, otherwise a ResourceIdentifierObject is added | 
| 56 | 56 | */ | 
| 57 | -	public function add($type, $id, array $attributes=[]) { | |
| 57 | +	public function add($type, $id, array $attributes = []) { | |
| 58 | 58 |  		if ($attributes === []) { | 
| 59 | 59 | $this->addResource(new ResourceIdentifierObject($type, $id)); | 
| 60 | 60 | } | 
| @@ -66,7 +66,7 @@ discard block | ||
| 66 | 66 | /** | 
| 67 | 67 | * @inheritDoc | 
| 68 | 68 | */ | 
| 69 | -	public function setPaginationLinks($previousHref=null, $nextHref=null, $firstHref=null, $lastHref=null) { | |
| 69 | +	public function setPaginationLinks($previousHref = null, $nextHref = null, $firstHref = null, $lastHref = null) { | |
| 70 | 70 |  		if ($previousHref !== null) { | 
| 71 | 71 |  			$this->addLink('prev', $previousHref); | 
| 72 | 72 | } | 
| @@ -95,7 +95,7 @@ discard block | ||
| 95 | 95 | * | 
| 96 | 96 | * @throws InputException if the resource is empty | 
| 97 | 97 | */ | 
| 98 | -	public function addResource(ResourceInterface $resource, array $options=[]) { | |
| 98 | +	public function addResource(ResourceInterface $resource, array $options = []) { | |
| 99 | 99 |  		if ($resource->getResource()->isEmpty()) { | 
| 100 | 100 |  			throw new InputException('does not make sense to add empty resources to a collection'); | 
| 101 | 101 | } | 
| @@ -40,7 +40,7 @@ | ||
| 40 | 40 | * | 
| 41 | 41 | * @throws DuplicateException | 
| 42 | 42 | */ | 
| 43 | -	public function claimUsedFields(array $fieldNames, $objectContainer, array $options=[]) { | |
| 43 | +	public function claimUsedFields(array $fieldNames, $objectContainer, array $options = []) { | |
| 44 | 44 | $options = array_merge(self::$defaults, $options); | 
| 45 | 45 | |
| 46 | 46 |  		foreach ($fieldNames as $fieldName) { | 
| @@ -21,7 +21,7 @@ discard block | ||
| 21 | 21 | * @param string $href | 
| 22 | 22 | * @param array $meta optional, if given a LinkObject is added, otherwise a link string is added | 
| 23 | 23 | */ | 
| 24 | -	public function addLink($key, $href, array $meta=[]) { | |
| 24 | +	public function addLink($key, $href, array $meta = []) { | |
| 25 | 25 | $this->ensureLinksObject(); | 
| 26 | 26 | $this->links->add($key, $href, $meta); | 
| 27 | 27 | } | 
| @@ -33,7 +33,7 @@ discard block | ||
| 33 | 33 | * @param string $href | 
| 34 | 34 | * @param array $meta optional, if given a LinkObject is added, otherwise a link string is added | 
| 35 | 35 | */ | 
| 36 | -	public function appendLink($key, $href, array $meta=[]) { | |
| 36 | +	public function appendLink($key, $href, array $meta = []) { | |
| 37 | 37 | $this->ensureLinksObject(); | 
| 38 | 38 | $this->links->append($key, $href, $meta); | 
| 39 | 39 | } | 
| @@ -36,7 +36,7 @@ discard block | ||
| 36 | 36 | * @param array $queryParameters all query parameters defined by the specification | 
| 37 | 37 | * @param array $document the request jsonapi document | 
| 38 | 38 | */ | 
| 39 | -	public function __construct($selfLink='', array $queryParameters=[], array $document=[]) { | |
| 39 | +	public function __construct($selfLink = '', array $queryParameters = [], array $document = []) { | |
| 40 | 40 | $this->selfLink = $selfLink; | 
| 41 | 41 | $this->queryParameters = $queryParameters; | 
| 42 | 42 | $this->document = $document; | 
| @@ -56,7 +56,7 @@ discard block | ||
| 56 | 56 | $document = $_POST; | 
| 57 | 57 |  		if ($document === [] && isset($_SERVER['CONTENT_TYPE'])) { | 
| 58 | 58 | $documentIsJsonapi = (strpos($_SERVER['CONTENT_TYPE'], Document::CONTENT_TYPE_OFFICIAL) !== false); | 
| 59 | - $documentIsJson = (strpos($_SERVER['CONTENT_TYPE'], Document::CONTENT_TYPE_DEBUG) !== false); | |
| 59 | + $documentIsJson = (strpos($_SERVER['CONTENT_TYPE'], Document::CONTENT_TYPE_DEBUG) !== false); | |
| 60 | 60 | |
| 61 | 61 |  			if ($documentIsJsonapi || $documentIsJson) { | 
| 62 | 62 |  				$document = json_decode(file_get_contents('php://input'), true); | 
| @@ -126,7 +126,7 @@ discard block | ||
| 126 | 126 |  	 * @param  array $options optional {@see RequestParser::$defaults} | 
| 127 | 127 | * @return string[]|array | 
| 128 | 128 | */ | 
| 129 | -	public function getIncludePaths(array $options=[]) { | |
| 129 | +	public function getIncludePaths(array $options = []) { | |
| 130 | 130 |  		$includePaths = explode(',', $this->queryParameters['include']); | 
| 131 | 131 | |
| 132 | 132 | $options = array_merge(self::$defaults, $options); | 
| @@ -191,7 +191,7 @@ discard block | ||
| 191 | 191 | * @var string $order one of the RequestParser::SORT_* constants | 
| 192 | 192 | * } | 
| 193 | 193 | */ | 
| 194 | -	public function getSortFields(array $options=[]) { | |
| 194 | +	public function getSortFields(array $options = []) { | |
| 195 | 195 |  		$fields = explode(',', $this->queryParameters['sort']); | 
| 196 | 196 | |
| 197 | 197 | $options = array_merge(self::$defaults, $options); | 
| @@ -31,7 +31,7 @@ discard block | ||
| 31 | 31 | /** | 
| 32 | 32 | * @param ErrorObject $errorObject optional | 
| 33 | 33 | */ | 
| 34 | -	public function __construct(ErrorObject $errorObject=null) { | |
| 34 | +	public function __construct(ErrorObject $errorObject = null) { | |
| 35 | 35 | parent::__construct(); | 
| 36 | 36 | |
| 37 | 37 |  		if ($errorObject !== null) { | 
| @@ -50,7 +50,7 @@ discard block | ||
| 50 | 50 | * | 
| 51 | 51 | * @throws InputException if $exception is not \Exception or \Throwable | 
| 52 | 52 | */ | 
| 53 | -	public static function fromException($exception, array $options=[]) { | |
| 53 | +	public static function fromException($exception, array $options = []) { | |
| 54 | 54 |  		if ($exception instanceof \Exception === false && $exception instanceof \Throwable === false) { | 
| 55 | 55 |  			throw new InputException('input is not a real exception in php5 or php7'); | 
| 56 | 56 | } | 
| @@ -73,7 +73,7 @@ discard block | ||
| 73 | 73 | * | 
| 74 | 74 | * @throws InputException if $exception is not \Exception or \Throwable | 
| 75 | 75 | */ | 
| 76 | -	public function addException($exception, array $options=[]) { | |
| 76 | +	public function addException($exception, array $options = []) { | |
| 77 | 77 |  		if ($exception instanceof \Exception === false && $exception instanceof \Throwable === false) { | 
| 78 | 78 |  			throw new InputException('input is not a real exception in php5 or php7'); | 
| 79 | 79 | } | 
| @@ -98,7 +98,7 @@ discard block | ||
| 98 | 98 | * @param string $specificAboutLink optional, human-friendly explanation of the specific error | 
| 99 | 99 | * @param string $genericTypeLink optional, human-friendly explanation of the generic type of error | 
| 100 | 100 | */ | 
| 101 | -	public function add($genericCode, $genericTitle, $specificDetails=null, $specificAboutLink=null, $genericTypeLink=null) { | |
| 101 | +	public function add($genericCode, $genericTitle, $specificDetails = null, $specificAboutLink = null, $genericTypeLink = null) { | |
| 102 | 102 | $errorObject = new ErrorObject($genericCode, $genericTitle, $specificDetails, $specificAboutLink, $genericTypeLink); | 
| 103 | 103 | |
| 104 | 104 | $this->addErrorObject($errorObject); | 
| @@ -46,7 +46,7 @@ discard block | ||
| 46 | 46 |  	 * @param  array      $options    optional {@see ResourceObject::$defaults} | 
| 47 | 47 | * @return ResourceObject | 
| 48 | 48 | */ | 
| 49 | -	public static function fromArray(array $attributes, $type=null, $id=null, array $options=[]) { | |
| 49 | +	public static function fromArray(array $attributes, $type = null, $id = null, array $options = []) { | |
| 50 | 50 |  		if (isset($attributes['id'])) { | 
| 51 | 51 |  			if ($id === null) { | 
| 52 | 52 | $id = $attributes['id']; | 
| @@ -68,7 +68,7 @@ discard block | ||
| 68 | 68 |  	 * @param  array      $options    optional {@see ResourceObject::$defaults} | 
| 69 | 69 | * @return ResourceObject | 
| 70 | 70 | */ | 
| 71 | -	public static function fromObject($attributes, $type=null, $id=null, array $options=[]) { | |
| 71 | +	public static function fromObject($attributes, $type = null, $id = null, array $options = []) { | |
| 72 | 72 | $array = Converter::objectToArray($attributes); | 
| 73 | 73 | |
| 74 | 74 | return self::fromArray($array, $type, $id, $options); | 
| @@ -81,7 +81,7 @@ discard block | ||
| 81 | 81 | * @param mixed $value | 
| 82 | 82 |  	 * @param array  $options optional {@see ResourceObject::$defaults} | 
| 83 | 83 | */ | 
| 84 | -	public function add($key, $value, array $options=[]) { | |
| 84 | +	public function add($key, $value, array $options = []) { | |
| 85 | 85 | $options = array_merge(self::$defaults, $options); | 
| 86 | 86 | |
| 87 | 87 |  		if ($this->attributes === null) { | 
| @@ -101,7 +101,7 @@ discard block | ||
| 101 | 101 |  	 * @param  array  $options  optional {@see ResourceObject::$defaults} | 
| 102 | 102 | * @return RelationshipObject | 
| 103 | 103 | */ | 
| 104 | -	public function addRelationship($key, $relation, array $links=[], array $meta=[], array $options=[]) { | |
| 104 | +	public function addRelationship($key, $relation, array $links = [], array $meta = [], array $options = []) { | |
| 105 | 105 | $relationshipObject = RelationshipObject::fromAnything($relation, $links, $meta); | 
| 106 | 106 | |
| 107 | 107 | $this->addRelationshipObject($key, $relationshipObject, $options); | 
| @@ -113,7 +113,7 @@ discard block | ||
| 113 | 113 | * @param string $href | 
| 114 | 114 | * @param array $meta optional, if given a LinkObject is added, otherwise a link string is added | 
| 115 | 115 | */ | 
| 116 | -	public function setSelfLink($href, array $meta=[]) { | |
| 116 | +	public function setSelfLink($href, array $meta = []) { | |
| 117 | 117 |  		$this->addLink('self', $href, $meta); | 
| 118 | 118 | } | 
| 119 | 119 | |
| @@ -125,7 +125,7 @@ discard block | ||
| 125 | 125 | * @param AttributesObject $attributesObject | 
| 126 | 126 |  	 * @param array            $options          optional {@see ResourceObject::$defaults} | 
| 127 | 127 | */ | 
| 128 | -	public function setAttributesObject(AttributesObject $attributesObject, array $options=[]) { | |
| 128 | +	public function setAttributesObject(AttributesObject $attributesObject, array $options = []) { | |
| 129 | 129 | $newKeys = $attributesObject->getKeys(); | 
| 130 | 130 | $this->validator->clearUsedFields(Validator::OBJECT_CONTAINER_ATTRIBUTES); | 
| 131 | 131 | $this->validator->claimUsedFields($newKeys, Validator::OBJECT_CONTAINER_ATTRIBUTES, $options); | 
| @@ -140,7 +140,7 @@ discard block | ||
| 140 | 140 | * | 
| 141 | 141 | * @throws DuplicateException if the resource is contained as a resource in the relationship | 
| 142 | 142 | */ | 
| 143 | -	public function addRelationshipObject($key, RelationshipObject $relationshipObject, array $options=[]) { | |
| 143 | +	public function addRelationshipObject($key, RelationshipObject $relationshipObject, array $options = []) { | |
| 144 | 144 |  		if ($relationshipObject->hasResource($this)) { | 
| 145 | 145 |  			throw new DuplicateException('can not add relation to self'); | 
| 146 | 146 | } | 
| @@ -199,7 +199,7 @@ discard block | ||
| 199 | 199 | /** | 
| 200 | 200 | * @inheritDoc | 
| 201 | 201 | */ | 
| 202 | -	public function getResource($identifierOnly=false) { | |
| 202 | +	public function getResource($identifierOnly = false) { | |
| 203 | 203 |  		if ($identifierOnly) { | 
| 204 | 204 | return ResourceIdentifierObject::fromResourceObject($this); | 
| 205 | 205 | } |