@@ -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,15 +127,15 @@ 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'])); |
|
136 | - $paginator->appends($queryParams); |
|
134 | + if ( $resource instanceof CollectionResource ) { |
|
135 | + $queryParams = array_diff_key( request()->all(), array_flip( [ 'page' ] ) ); |
|
136 | + $paginator->appends( $queryParams ); |
|
137 | 137 | |
138 | - $resource->setPaginator(new IlluminatePaginatorAdapter($paginator)); |
|
138 | + $resource->setPaginator( new IlluminatePaginatorAdapter( $paginator ) ); |
|
139 | 139 | } |
140 | 140 | |
141 | 141 | return $resource; |
@@ -147,9 +147,9 @@ discard block |
||
147 | 147 | * @param \Illuminate\Database\Eloquent\Relations\Pivot $pivot |
148 | 148 | * @return \League\Fractal\Resource\ResourceInterface |
149 | 149 | */ |
150 | - protected function makeFromPivot(Pivot $pivot):ResourceInterface |
|
150 | + protected function makeFromPivot( Pivot $pivot ):ResourceInterface |
|
151 | 151 | { |
152 | - return static::makeFromModel($pivot); |
|
152 | + return static::makeFromModel( $pivot ); |
|
153 | 153 | } |
154 | 154 | |
155 | 155 | /** |
@@ -158,8 +158,8 @@ discard block |
||
158 | 158 | * @param \Illuminate\Database\Eloquent\Relations\Relation $relation |
159 | 159 | * @return \League\Fractal\Resource\ResourceInterface |
160 | 160 | */ |
161 | - protected function makeFromRelation(Relation $relation):ResourceInterface |
|
161 | + protected function makeFromRelation( Relation $relation ):ResourceInterface |
|
162 | 162 | { |
163 | - return static::makeFromCollection($relation->get()); |
|
163 | + return static::makeFromCollection( $relation->get() ); |
|
164 | 164 | } |
165 | 165 | } |