@@ -20,8 +20,9 @@ class JsonApiResource extends JsonResource
2020 /**
2121 * Create a new resource instance.
2222 *
23- * @param mixed $resource
24- * @param bool|null $authorize
23+ * @param mixed $resource
24+ * @param bool|null $authorize
25+ *
2526 * @return void
2627 */
2728 public function __construct ($ resource , $ authorize = null )
@@ -30,7 +31,7 @@ public function __construct($resource, $authorize = null)
3031 $ this ->authorize = $ authorize ;
3132 }
3233
33- if (! $ this ->authorize ($ resource )) {
34+ if (!$ this ->authorize ($ resource )) {
3435 $ this ->resource = new MissingValue ();
3536 } else {
3637 $ this ->resource = $ resource ;
@@ -41,15 +42,16 @@ public function __construct($resource, $authorize = null)
4142 /**
4243 * Transform the resource into an array.
4344 *
44- * @param \Illuminate\Http\Request $request
45+ * @param \Illuminate\Http\Request $request
46+ *
4547 * @return array
4648 */
4749 public function toArray ($ request )
4850 {
4951 if ($ this ->evaluateResponse ()) {
5052 return [
5153 $ this ->merge ($ this ->getResourceIdentifier ()),
52- 'attributes ' => $ this ->getAttributes (),
54+ 'attributes ' => $ this ->getAttributes (),
5355 'relationships ' => $ this ->when (
5456 $ this ->relationships , $ this ->relationships
5557 ),
@@ -66,9 +68,9 @@ public function toArray($request)
6668 */
6769 protected function evaluateResponse ()
6870 {
69- return ! is_array ($ this ->resource )
70- && ! is_null ($ this ->resource )
71- && ! $ this ->resource instanceof MissingValue;
71+ return !is_array ($ this ->resource )
72+ && !is_null ($ this ->resource )
73+ && !$ this ->resource instanceof MissingValue;
7274 }
7375
7476 /**
@@ -80,7 +82,7 @@ public function getResourceIdentifier()
8082 {
8183 return [
8284 $ this ->resource ->getKeyName () => (string ) $ this ->resource ->getKey (),
83- 'type ' => Str::snake (class_basename ($ this ->resource )),
85+ 'type ' => Str::snake (class_basename ($ this ->resource )),
8486 ];
8587 }
8688
@@ -92,7 +94,7 @@ public function getResourceIdentifier()
9294 protected function getAttributes ()
9395 {
9496 return array_filter ($ this ->resource ->attributesToArray (), function ($ key ) {
95- return ! Str::endsWith ($ key , '_id ' ) && $ key !== $ this ->resource ->getKeyName ();
97+ return !Str::endsWith ($ key , '_id ' ) && $ key !== $ this ->resource ->getKeyName ();
9698 }, ARRAY_FILTER_USE_KEY );
9799 }
98100}
0 commit comments