@@ -33,7 +33,7 @@ discard block |
||
| 33 | 33 | * @param object|object[] $resource |
| 34 | 34 | * @return array<string, array>|array<array<string, array>> |
| 35 | 35 | */ |
| 36 | - public function serialize(object|array $resource): array |
|
| 36 | + public function serialize(object | array $resource): array |
|
| 37 | 37 | { |
| 38 | 38 | return is_array($resource) |
| 39 | 39 | ? array_map(fn($resource) => $this->serializeResource($resource), $resource) |
@@ -85,7 +85,7 @@ discard block |
||
| 85 | 85 | * @param string[]|null $fields |
| 86 | 86 | * @return array<string, mixed>|null |
| 87 | 87 | */ |
| 88 | - protected function serializeAttributes(object $resource, array|null $fields): array|null |
|
| 88 | + protected function serializeAttributes(object $resource, array | null $fields): array | null |
|
| 89 | 89 | { |
| 90 | 90 | if (($this->options[static::OPTIONS_NO_ATTRIBUTES] ?? false) === true) return null; |
| 91 | 91 | |
@@ -93,7 +93,7 @@ discard block |
||
| 93 | 93 | |
| 94 | 94 | $attributes = array_filter( |
| 95 | 95 | $this->metadata->getResourceAttributes($resource), |
| 96 | - fn ($key) => is_null($fields) || in_array($key, $fields) |
|
| 96 | + fn($key) => is_null($fields) || in_array($key, $fields) |
|
| 97 | 97 | ); |
| 98 | 98 | |
| 99 | 99 | foreach ($attributes as $key => $attribute) { |
@@ -107,7 +107,7 @@ discard block |
||
| 107 | 107 | * @param object $resource |
| 108 | 108 | * @return array<string, array>|null |
| 109 | 109 | */ |
| 110 | - protected function serializeRelationships(object $resource): array|null |
|
| 110 | + protected function serializeRelationships(object $resource): array | null |
|
| 111 | 111 | { |
| 112 | 112 | if ($this->includeset === null || count($this->includeset) === 0) return null; |
| 113 | 113 | |
@@ -87,7 +87,9 @@ discard block |
||
| 87 | 87 | */ |
| 88 | 88 | protected function serializeAttributes(object $resource, array|null $fields): array|null |
| 89 | 89 | { |
| 90 | - if (($this->options[static::OPTIONS_NO_ATTRIBUTES] ?? false) === true) return null; |
|
| 90 | + if (($this->options[static::OPTIONS_NO_ATTRIBUTES] ?? false) === true) { |
|
| 91 | + return null; |
|
| 92 | + } |
|
| 91 | 93 | |
| 92 | 94 | $result = []; |
| 93 | 95 | |
@@ -109,14 +111,18 @@ discard block |
||
| 109 | 111 | */ |
| 110 | 112 | protected function serializeRelationships(object $resource): array|null |
| 111 | 113 | { |
| 112 | - if ($this->includeset === null || count($this->includeset) === 0) return null; |
|
| 114 | + if ($this->includeset === null || count($this->includeset) === 0) { |
|
| 115 | + return null; |
|
| 116 | + } |
|
| 113 | 117 | |
| 114 | 118 | $relationships = []; |
| 115 | 119 | $relationshipsMap = $this->metadata->getResourceRelationships($resource); |
| 116 | 120 | |
| 117 | 121 | foreach ($this->includeset as $relation => $childIncludeset) { |
| 118 | 122 | // TODO: Maybe we should throw an exception here |
| 119 | - if (!isset($relationshipsMap[$relation])) continue; |
|
| 123 | + if (!isset($relationshipsMap[$relation])) { |
|
| 124 | + continue; |
|
| 125 | + } |
|
| 120 | 126 | |
| 121 | 127 | $value = $relationshipsMap[$relation]->getValue($resource); |
| 122 | 128 | |
@@ -25,7 +25,9 @@ |
||
| 25 | 25 | $parserInclude = explode(Includeset::RELATION_SEPARATOR, $item, 2); |
| 26 | 26 | $relation = array_shift($parserInclude); |
| 27 | 27 | |
| 28 | - if (empty($relation)) continue; |
|
| 28 | + if (empty($relation)) { |
|
| 29 | + continue; |
|
| 30 | + } |
|
| 29 | 31 | |
| 30 | 32 | $rawChildren = array_shift($parserInclude) ?? ''; |
| 31 | 33 | |
@@ -18,7 +18,7 @@ discard block |
||
| 18 | 18 | * |
| 19 | 19 | * @return array<string, string>|null |
| 20 | 20 | */ |
| 21 | - public function resourceLinks(object $resource): array|null; |
|
| 21 | + public function resourceLinks(object $resource): array | null; |
|
| 22 | 22 | |
| 23 | 23 | /** |
| 24 | 24 | * Provides links data for resource relation. |
@@ -36,5 +36,5 @@ discard block |
||
| 36 | 36 | * |
| 37 | 37 | * @return array<string, string>|null |
| 38 | 38 | */ |
| 39 | - public function relationshipLinks(object $resource, string $relationship): array|null; |
|
| 39 | + public function relationshipLinks(object $resource, string $relationship): array | null; |
|
| 40 | 40 | } |
| 41 | 41 | \ No newline at end of file |
@@ -16,7 +16,7 @@ discard block |
||
| 16 | 16 | * @param object $resource |
| 17 | 17 | * @return array<string, string>|null |
| 18 | 18 | */ |
| 19 | - public function resourceLinks(object $resource): array|null |
|
| 19 | + public function resourceLinks(object $resource): array | null |
|
| 20 | 20 | { |
| 21 | 21 | $meta = $this->metadata->getResourceMeta($resource); |
| 22 | 22 | $type = $meta->getType(); |
@@ -32,7 +32,7 @@ discard block |
||
| 32 | 32 | * @param string $relationship |
| 33 | 33 | * @return array<string, string>|null |
| 34 | 34 | */ |
| 35 | - public function relationshipLinks(object $resource, string $relationship): array|null |
|
| 35 | + public function relationshipLinks(object $resource, string $relationship): array | null |
|
| 36 | 36 | { |
| 37 | 37 | $links = []; |
| 38 | 38 | |