@@ -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 | |
@@ -46,7 +46,7 @@ discard block |
||
| 46 | 46 | /** |
| 47 | 47 | * encode to json with these default options |
| 48 | 48 | */ |
| 49 | - 'encodeOptions' => JSON_UNESCAPED_SLASHES|JSON_UNESCAPED_UNICODE, |
|
| 49 | + 'encodeOptions' => JSON_UNESCAPED_SLASHES | JSON_UNESCAPED_UNICODE, |
|
| 50 | 50 | |
| 51 | 51 | /** |
| 52 | 52 | * encode to human-readable json, useful when debugging |
@@ -92,7 +92,7 @@ discard block |
||
| 92 | 92 | * |
| 93 | 93 | * @throws InputException if the $level is Document::LEVEL_JSONAPI, Document::LEVEL_RESOURCE, or unknown |
| 94 | 94 | */ |
| 95 | - public function addLink($key, $href, array $meta=[], $level=Document::LEVEL_ROOT) { |
|
| 95 | + public function addLink($key, $href, array $meta = [], $level = Document::LEVEL_ROOT) { |
|
| 96 | 96 | if ($level === Document::LEVEL_ROOT) { |
| 97 | 97 | if ($this->links === null) { |
| 98 | 98 | $this->setLinksObject(new LinksObject()); |
@@ -118,7 +118,7 @@ discard block |
||
| 118 | 118 | * @param array $meta optional, if given a LinkObject is added, otherwise a link string is added |
| 119 | 119 | * @param string $level one of the Document::LEVEL_* constants, optional, defaults to Document::LEVEL_ROOT |
| 120 | 120 | */ |
| 121 | - public function setSelfLink($href, array $meta=[], $level=Document::LEVEL_ROOT) { |
|
| 121 | + public function setSelfLink($href, array $meta = [], $level = Document::LEVEL_ROOT) { |
|
| 122 | 122 | $this->addLink('self', $href, $meta, $level); |
| 123 | 123 | } |
| 124 | 124 | |
@@ -130,7 +130,7 @@ discard block |
||
| 130 | 130 | * @throws InputException if the $level is unknown |
| 131 | 131 | * @throws InputException if the $level is Document::LEVEL_RESOURCE |
| 132 | 132 | */ |
| 133 | - public function addMeta($key, $value, $level=Document::LEVEL_ROOT) { |
|
| 133 | + public function addMeta($key, $value, $level = Document::LEVEL_ROOT) { |
|
| 134 | 134 | if ($level === Document::LEVEL_ROOT) { |
| 135 | 135 | if ($this->meta === null) { |
| 136 | 136 | $this->setMetaObject(new MetaObject()); |
@@ -231,7 +231,7 @@ discard block |
||
| 231 | 231 | /** |
| 232 | 232 | * @inheritDoc |
| 233 | 233 | */ |
| 234 | - public function toJson(array $options=[]) { |
|
| 234 | + public function toJson(array $options = []) { |
|
| 235 | 235 | $options = array_merge(self::$defaults, $options); |
| 236 | 236 | |
| 237 | 237 | $array = ($options['array'] !== null) ? $options['array'] : $this->toArray(); |
@@ -255,7 +255,7 @@ discard block |
||
| 255 | 255 | /** |
| 256 | 256 | * @inheritDoc |
| 257 | 257 | */ |
| 258 | - public function sendResponse(array $options=[]) { |
|
| 258 | + public function sendResponse(array $options = []) { |
|
| 259 | 259 | $options = array_merge(self::$defaults, $options); |
| 260 | 260 | |
| 261 | 261 | if ($this->httpStatusCode === 204) { |
@@ -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); |