@@ -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 | } |
@@ -47,7 +47,7 @@ |
||
| 47 | 47 | * @param string $href |
| 48 | 48 | * @param array $meta optional, if given a LinkObject is added, otherwise a link string is added |
| 49 | 49 | */ |
| 50 | - public function add($href, array $meta=[]) { |
|
| 50 | + public function add($href, array $meta = []) { |
|
| 51 | 51 | if ($meta === []) { |
| 52 | 52 | $this->addLinkString($href); |
| 53 | 53 | } |
@@ -35,7 +35,7 @@ discard block |
||
| 35 | 35 | * @throws InputException if $type is unknown |
| 36 | 36 | */ |
| 37 | 37 | public function __construct($type) { |
| 38 | - if (in_array($type, [RelationshipObject::TO_ONE, RelationshipObject::TO_MANY], $strict=true) === false) { |
|
| 38 | + if (in_array($type, [RelationshipObject::TO_ONE, RelationshipObject::TO_MANY], $strict = true) === false) { |
|
| 39 | 39 | throw new InputException('unknown relationship type "'.$type.'"'); |
| 40 | 40 | } |
| 41 | 41 | |
@@ -56,7 +56,7 @@ discard block |
||
| 56 | 56 | * |
| 57 | 57 | * @throws InputException if $relation is not one of the supported formats |
| 58 | 58 | */ |
| 59 | - public static function fromAnything($relation, array $links=[], array $meta=[]) { |
|
| 59 | + public static function fromAnything($relation, array $links = [], array $meta = []) { |
|
| 60 | 60 | if (is_array($relation)) { |
| 61 | 61 | $relation = CollectionDocument::fromResources(...$relation); |
| 62 | 62 | } |
@@ -84,7 +84,7 @@ discard block |
||
| 84 | 84 | * @param string $type optional, one of the RelationshipObject::TO_* constants, defaults to RelationshipObject::TO_ONE |
| 85 | 85 | * @return RelationshipObject |
| 86 | 86 | */ |
| 87 | - public static function fromResource(ResourceInterface $resource, array $links=[], array $meta=[], $type=RelationshipObject::TO_ONE) { |
|
| 87 | + public static function fromResource(ResourceInterface $resource, array $links = [], array $meta = [], $type = RelationshipObject::TO_ONE) { |
|
| 88 | 88 | $relationshipObject = new self($type); |
| 89 | 89 | |
| 90 | 90 | if ($type === RelationshipObject::TO_ONE) { |
@@ -110,7 +110,7 @@ discard block |
||
| 110 | 110 | * @param array $meta optional |
| 111 | 111 | * @return RelationshipObject |
| 112 | 112 | */ |
| 113 | - public static function fromCollectionDocument(CollectionDocument $collectionDocument, array $links=[], array $meta=[]) { |
|
| 113 | + public static function fromCollectionDocument(CollectionDocument $collectionDocument, array $links = [], array $meta = []) { |
|
| 114 | 114 | $relationshipObject = new self(RelationshipObject::TO_MANY); |
| 115 | 115 | |
| 116 | 116 | foreach ($collectionDocument->getContainedResources() as $resource) { |
@@ -131,7 +131,7 @@ discard block |
||
| 131 | 131 | * @param string $href |
| 132 | 132 | * @param array $meta optional, if given a LinkObject is added, otherwise a link string is added |
| 133 | 133 | */ |
| 134 | - public function setSelfLink($href, array $meta=[]) { |
|
| 134 | + public function setSelfLink($href, array $meta = []) { |
|
| 135 | 135 | $this->addLink('self', $href, $meta); |
| 136 | 136 | } |
| 137 | 137 | |
@@ -139,7 +139,7 @@ discard block |
||
| 139 | 139 | * @param string $href |
| 140 | 140 | * @param array $meta optional, if given a LinkObject is added, otherwise a link string is added |
| 141 | 141 | */ |
| 142 | - public function setRelatedLink($href, array $meta=[]) { |
|
| 142 | + public function setRelatedLink($href, array $meta = []) { |
|
| 143 | 143 | $this->addLink('related', $href, $meta); |
| 144 | 144 | } |
| 145 | 145 | |
@@ -148,7 +148,7 @@ discard block |
||
| 148 | 148 | * |
| 149 | 149 | * @throws InputException if used on a to-one relationship |
| 150 | 150 | */ |
| 151 | - public function setPaginationLinks($previousHref=null, $nextHref=null, $firstHref=null, $lastHref=null) { |
|
| 151 | + public function setPaginationLinks($previousHref = null, $nextHref = null, $firstHref = null, $lastHref = null) { |
|
| 152 | 152 | if ($this->type === RelationshipObject::TO_ONE) { |
| 153 | 153 | throw new InputException('can not add pagination links to a to-one relationship'); |
| 154 | 154 | } |
@@ -289,13 +289,13 @@ discard block |
||
| 289 | 289 | if ($this->type === RelationshipObject::TO_ONE) { |
| 290 | 290 | $array['data'] = null; |
| 291 | 291 | if ($this->resource !== null) { |
| 292 | - $array['data'] = $this->resource->getResource($identifierOnly=true)->toArray(); |
|
| 292 | + $array['data'] = $this->resource->getResource($identifierOnly = true)->toArray(); |
|
| 293 | 293 | } |
| 294 | 294 | } |
| 295 | 295 | if ($this->type === RelationshipObject::TO_MANY) { |
| 296 | 296 | $array['data'] = []; |
| 297 | 297 | foreach ($this->resources as $resource) { |
| 298 | - $array['data'][] = $resource->getResource($identifierOnly=true)->toArray(); |
|
| 298 | + $array['data'][] = $resource->getResource($identifierOnly = true)->toArray(); |
|
| 299 | 299 | } |
| 300 | 300 | } |
| 301 | 301 | if ($this->meta !== null && $this->meta->isEmpty() === false) { |
@@ -28,7 +28,7 @@ |
||
| 28 | 28 | * @param array $meta optional |
| 29 | 29 | * @return RelationshipObject |
| 30 | 30 | */ |
| 31 | - public function add($key, $relation, array $links=[], array $meta=[]) { |
|
| 31 | + public function add($key, $relation, array $links = [], array $meta = []) { |
|
| 32 | 32 | $relationshipObject = RelationshipObject::fromAnything($relation, $links, $meta); |
| 33 | 33 | |
| 34 | 34 | $this->addRelationshipObject($key, $relationshipObject); |
@@ -29,7 +29,7 @@ discard block |
||
| 29 | 29 | * @param string $type optional |
| 30 | 30 | * @param string|int $id optional |
| 31 | 31 | */ |
| 32 | - public function __construct($type=null, $id=null) { |
|
| 32 | + public function __construct($type = null, $id = null) { |
|
| 33 | 33 | $this->validator = new Validator(); |
| 34 | 34 | |
| 35 | 35 | if ($type !== null) { |
@@ -40,8 +40,8 @@ discard block |
||
| 40 | 40 | } |
| 41 | 41 | |
| 42 | 42 | // always mark as used, as these keys are reserved |
| 43 | - $this->validator->claimUsedFields($fieldNames=['type'], Validator::OBJECT_CONTAINER_TYPE); |
|
| 44 | - $this->validator->claimUsedFields($fieldNames=['id'], Validator::OBJECT_CONTAINER_ID); |
|
| 43 | + $this->validator->claimUsedFields($fieldNames = ['type'], Validator::OBJECT_CONTAINER_TYPE); |
|
| 44 | + $this->validator->claimUsedFields($fieldNames = ['id'], Validator::OBJECT_CONTAINER_ID); |
|
| 45 | 45 | } |
| 46 | 46 | |
| 47 | 47 | /** |
@@ -194,7 +194,7 @@ discard block |
||
| 194 | 194 | /** |
| 195 | 195 | * @inheritDoc |
| 196 | 196 | */ |
| 197 | - public function getResource($identifierOnly=false) { |
|
| 197 | + public function getResource($identifierOnly = false) { |
|
| 198 | 198 | return $this; |
| 199 | 199 | } |
| 200 | 200 | } |
@@ -49,7 +49,7 @@ discard block |
||
| 49 | 49 | * @param string $href |
| 50 | 50 | * @param array $meta optional, if given a LinkObject is added, otherwise a link string is added |
| 51 | 51 | */ |
| 52 | - public function add($key, $href, array $meta=[]) { |
|
| 52 | + public function add($key, $href, array $meta = []) { |
|
| 53 | 53 | if ($meta === []) { |
| 54 | 54 | $this->addLinkString($key, $href); |
| 55 | 55 | } |
@@ -69,7 +69,7 @@ discard block |
||
| 69 | 69 | * |
| 70 | 70 | * @throws DuplicateException if another link is already using that $key but is not an array |
| 71 | 71 | */ |
| 72 | - public function append($key, $href, array $meta=[]) { |
|
| 72 | + public function append($key, $href, array $meta = []) { |
|
| 73 | 73 | Validator::checkMemberName($key); |
| 74 | 74 | |
| 75 | 75 | if (isset($this->links[$key]) === false) { |
@@ -18,7 +18,7 @@ |
||
| 18 | 18 | * @param string $href |
| 19 | 19 | * @param array $meta optional |
| 20 | 20 | */ |
| 21 | - public function __construct($href=null, array $meta=[]) { |
|
| 21 | + public function __construct($href = null, array $meta = []) { |
|
| 22 | 22 | if ($href !== null) { |
| 23 | 23 | $this->setHref($href); |
| 24 | 24 | } |
@@ -14,7 +14,7 @@ |
||
| 14 | 14 | * @param array $aliases optional |
| 15 | 15 | * @param array $meta optional |
| 16 | 16 | */ |
| 17 | - public function __construct($href, array $aliases=[], array $meta=[]) { |
|
| 17 | + public function __construct($href, array $aliases = [], array $meta = []) { |
|
| 18 | 18 | parent::__construct($href, $meta); |
| 19 | 19 | |
| 20 | 20 | $this->aliases = $aliases; |