@@ -46,17 +46,17 @@ discard block |
||
46 | 46 | * @param mixed|null $data |
47 | 47 | * @return \League\Fractal\Resource\ResourceInterface |
48 | 48 | */ |
49 | - public function make($data = null) |
|
49 | + public function make( $data = null ) |
|
50 | 50 | { |
51 | - if (is_null($data)) { |
|
51 | + if ( is_null( $data ) ) { |
|
52 | 52 | return new NullResource(); |
53 | - } elseif (is_array($data)) { |
|
54 | - return static::makeFromArray($data); |
|
53 | + } elseif ( is_array( $data ) ) { |
|
54 | + return static::makeFromArray( $data ); |
|
55 | 55 | } |
56 | 56 | |
57 | - $method = static::getMakeMethod($data); |
|
57 | + $method = static::getMakeMethod( $data ); |
|
58 | 58 | |
59 | - return static::$method($data); |
|
59 | + return static::$method( $data ); |
|
60 | 60 | } |
61 | 61 | |
62 | 62 | /** |
@@ -66,15 +66,15 @@ discard block |
||
66 | 66 | * @return string |
67 | 67 | * @throws \InvalidArgumentException |
68 | 68 | */ |
69 | - protected function getMakeMethod($data):string |
|
69 | + protected function getMakeMethod( $data ):string |
|
70 | 70 | { |
71 | - foreach (static::MAKE_METHODS as $class => $method) { |
|
72 | - if ($data instanceof $class) { |
|
71 | + foreach ( static::MAKE_METHODS as $class => $method ) { |
|
72 | + if ( $data instanceof $class ) { |
|
73 | 73 | return $method; |
74 | 74 | } |
75 | 75 | } |
76 | 76 | |
77 | - throw new InvalidArgumentException('Given data cannot be transformed.'); |
|
77 | + throw new InvalidArgumentException( 'Given data cannot be transformed.' ); |
|
78 | 78 | } |
79 | 79 | |
80 | 80 | /** |
@@ -83,9 +83,9 @@ discard block |
||
83 | 83 | * @param \Illuminate\Database\Eloquent\Model $model |
84 | 84 | * @return \League\Fractal\Resource\ResourceInterface |
85 | 85 | */ |
86 | - protected function makeFromModel(Model $model):ResourceInterface |
|
86 | + protected function makeFromModel( Model $model ):ResourceInterface |
|
87 | 87 | { |
88 | - return new ItemResource($model); |
|
88 | + return new ItemResource( $model ); |
|
89 | 89 | } |
90 | 90 | |
91 | 91 | /** |
@@ -94,9 +94,9 @@ discard block |
||
94 | 94 | * @param array $array |
95 | 95 | * @return \League\Fractal\Resource\ResourceInterface |
96 | 96 | */ |
97 | - protected function makeFromArray(array $array):ResourceInterface |
|
97 | + protected function makeFromArray( array $array ):ResourceInterface |
|
98 | 98 | { |
99 | - return empty($array) ? new NullResource() : new CollectionResource($array); |
|
99 | + return empty($array) ? new NullResource() : new CollectionResource( $array ); |
|
100 | 100 | } |
101 | 101 | |
102 | 102 | /** |
@@ -105,9 +105,9 @@ discard block |
||
105 | 105 | * @param \Illuminate\Support\Collection $collection |
106 | 106 | * @return \League\Fractal\Resource\ResourceInterface |
107 | 107 | */ |
108 | - protected function makeFromCollection(Collection $collection):ResourceInterface |
|
108 | + protected function makeFromCollection( Collection $collection ):ResourceInterface |
|
109 | 109 | { |
110 | - return static::makeFromArray($collection->all()); |
|
110 | + return static::makeFromArray( $collection->all() ); |
|
111 | 111 | } |
112 | 112 | |
113 | 113 | /** |
@@ -116,9 +116,9 @@ discard block |
||
116 | 116 | * @param \Illuminate\Database\Eloquent\Builder $query |
117 | 117 | * @return \League\Fractal\Resource\ResourceInterface |
118 | 118 | */ |
119 | - protected function makeFromBuilder(Builder $query):ResourceInterface |
|
119 | + protected function makeFromBuilder( Builder $query ):ResourceInterface |
|
120 | 120 | { |
121 | - return static::makeFromCollection($query->get()); |
|
121 | + return static::makeFromCollection( $query->get() ); |
|
122 | 122 | } |
123 | 123 | |
124 | 124 | /** |
@@ -127,17 +127,17 @@ discard block |
||
127 | 127 | * @param \Illuminate\Contracts\Pagination\LengthAwarePaginator $paginator |
128 | 128 | * @return \League\Fractal\Resource\ResourceInterface |
129 | 129 | */ |
130 | - protected function makeFromPaginator(Paginator $paginator):ResourceInterface |
|
130 | + protected function makeFromPaginator( Paginator $paginator ):ResourceInterface |
|
131 | 131 | { |
132 | - $resource = static::makeFromCollection($paginator->getCollection()); |
|
132 | + $resource = static::makeFromCollection( $paginator->getCollection() ); |
|
133 | 133 | |
134 | - if ($resource instanceof CollectionResource) { |
|
135 | - $queryParams = array_diff_key(request()->all(), array_flip(['page'])); |
|
134 | + if ( $resource instanceof CollectionResource ) { |
|
135 | + $queryParams = array_diff_key( request()->all(), array_flip( [ 'page' ] ) ); |
|
136 | 136 | |
137 | - $paginator = new IlluminatePaginatorAdapter($paginator); |
|
138 | - $paginator->getPaginator()->appends($queryParams); |
|
137 | + $paginator = new IlluminatePaginatorAdapter( $paginator ); |
|
138 | + $paginator->getPaginator()->appends( $queryParams ); |
|
139 | 139 | |
140 | - $resource->setPaginator($paginator); |
|
140 | + $resource->setPaginator( $paginator ); |
|
141 | 141 | } |
142 | 142 | |
143 | 143 | return $resource; |
@@ -149,9 +149,9 @@ discard block |
||
149 | 149 | * @param \Illuminate\Database\Eloquent\Relations\Pivot $pivot |
150 | 150 | * @return \League\Fractal\Resource\ResourceInterface |
151 | 151 | */ |
152 | - protected function makeFromPivot(Pivot $pivot):ResourceInterface |
|
152 | + protected function makeFromPivot( Pivot $pivot ):ResourceInterface |
|
153 | 153 | { |
154 | - return static::makeFromModel($pivot); |
|
154 | + return static::makeFromModel( $pivot ); |
|
155 | 155 | } |
156 | 156 | |
157 | 157 | /** |
@@ -160,8 +160,8 @@ discard block |
||
160 | 160 | * @param \Illuminate\Database\Eloquent\Relations\Relation $relation |
161 | 161 | * @return \League\Fractal\Resource\ResourceInterface |
162 | 162 | */ |
163 | - protected function makeFromRelation(Relation $relation):ResourceInterface |
|
163 | + protected function makeFromRelation( Relation $relation ):ResourceInterface |
|
164 | 164 | { |
165 | - return static::makeFromCollection($relation->get()); |
|
165 | + return static::makeFromCollection( $relation->get() ); |
|
166 | 166 | } |
167 | 167 | } |