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

Commit ef35378

Browse files
committed
Merge pull request #40 from tobscure/analysis-8jJGr8
Applied fixes from StyleCI
2 parents dcaed38 + c34e4ea commit ef35378

File tree

3 files changed

+23
-18
lines changed

3 files changed

+23
-18
lines changed

src/AbstractSerializer.php

Lines changed: 13 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,8 @@
1111

1212
namespace Tobscure\JsonApi;
1313

14-
use Tobscure\JsonApi\Elements\Resource;
1514
use Tobscure\JsonApi\Elements\Collection;
15+
use Tobscure\JsonApi\Elements\Resource;
1616

1717
/**
1818
* This is the abstract serializer class.
@@ -48,12 +48,14 @@ public function __construct(array $include = [], array $link = [])
4848

4949
/**
5050
* @param $model
51+
*
5152
* @return mixed
5253
*/
5354
abstract protected function getAttributes($model);
5455

5556
/**
5657
* @param $model
58+
*
5759
* @return mixed
5860
*/
5961
protected function getId($model)
@@ -79,12 +81,13 @@ public function setLink($link)
7981

8082
/**
8183
* @param $data
84+
*
8285
* @return Collection|null
8386
*/
8487
public function collection($data)
8588
{
8689
if (empty($data)) {
87-
return null;
90+
return;
8891
}
8992

9093
$resources = [];
@@ -98,23 +101,24 @@ public function collection($data)
98101

99102
/**
100103
* @param object|array $data
104+
*
101105
* @return Resource|null
102106
*/
103107
public function resource($data)
104108
{
105109
if (empty($data)) {
106-
return null;
110+
return;
107111
}
108112

109-
if (! is_object($data)) {
113+
if (!is_object($data)) {
110114
return new Resource($this->type, $data);
111115
}
112116

113117
$included = $links = [];
114118

115119
$relationships = [
116120
'link' => $this->parseRelationshipPaths($this->link),
117-
'include' => $this->parseRelationshipPaths($this->include)
121+
'include' => $this->parseRelationshipPaths($this->include),
118122
];
119123

120124
foreach (['link', 'include'] as $type) {
@@ -133,7 +137,7 @@ public function resource($data)
133137
}
134138

135139
if ($method && $element) {
136-
if (! ($element instanceof Relationship)) {
140+
if (!($element instanceof Relationship)) {
137141
$element = new Relationship($element);
138142
}
139143
if ($include) {
@@ -161,7 +165,7 @@ protected function getRelationshipFromMethod($name)
161165
}
162166

163167
/**
164-
* Given a flat array of relationship paths like:
168+
* Given a flat array of relationship paths like:.
165169
*
166170
* ['user', 'user.employer', 'user.employer.country', 'comments']
167171
*
@@ -171,6 +175,7 @@ protected function getRelationshipFromMethod($name)
171175
* ['user' => ['employer', 'employer.country'], 'comments' => []]
172176
*
173177
* @param array $paths
178+
*
174179
* @return array
175180
*/
176181
protected function parseRelationshipPaths(array $paths)
@@ -180,7 +185,7 @@ protected function parseRelationshipPaths(array $paths)
180185
foreach ($paths as $path) {
181186
list($primary, $nested) = array_pad(explode('.', $path, 2), 2, null);
182187

183-
if (! isset($tree[$primary])) {
188+
if (!isset($tree[$primary])) {
184189
$tree[$primary] = [];
185190
}
186191

src/Document.php

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ public function addIncluded($link)
3737
foreach ($resources as $k => $resource) {
3838
// If the resource doesn't have any attributes, then we don't need to
3939
// put it into the included part of the document.
40-
if (! $resource->getAttributes()) {
40+
if (!$resource->getAttributes()) {
4141
unset($resources[$k]);
4242
} else {
4343
foreach ($resource->getIncluded() as $link) {
@@ -111,27 +111,27 @@ public function toArray()
111111
{
112112
$document = [];
113113

114-
if (! empty($this->links)) {
114+
if (!empty($this->links)) {
115115
ksort($this->links);
116116
$document['links'] = $this->links;
117117
}
118118

119-
if (! empty($this->data)) {
119+
if (!empty($this->data)) {
120120
$document['data'] = $this->data->toArray();
121121
}
122122

123-
if (! empty($this->included)) {
123+
if (!empty($this->included)) {
124124
$document['included'] = [];
125125
foreach ($this->included as $resource) {
126126
$document['included'][] = $resource->toArray();
127127
}
128128
}
129129

130-
if (! empty($this->meta)) {
130+
if (!empty($this->meta)) {
131131
$document['meta'] = $this->meta;
132132
}
133133

134-
if (! empty($this->errors)) {
134+
if (!empty($this->errors)) {
135135
$document['errors'] = $this->errors;
136136
}
137137

src/Relationship.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -80,19 +80,19 @@ public function toArray()
8080
{
8181
$link = [];
8282

83-
if (! empty($this->data)) {
83+
if (!empty($this->data)) {
8484
$link['data'] = $this->data->toArray(false);
8585
}
8686

87-
if (! empty($this->self)) {
87+
if (!empty($this->self)) {
8888
$link['self'] = $this->self;
8989
}
9090

91-
if (! empty($this->related)) {
91+
if (!empty($this->related)) {
9292
$link['related'] = $this->related;
9393
}
9494

95-
if (! empty($this->meta)) {
95+
if (!empty($this->meta)) {
9696
$link['meta'] = $this->meta;
9797
}
9898

0 commit comments

Comments
 (0)