Code Duplication    Length = 12-13 lines in 2 locations

src/Responder.php 2 locations

@@ 132-143 (lines=12) @@
129
     * @param  Transformer|null $transformer
130
     * @return ResourceInterface
131
     */
132
    protected function transformModel( Transformable $model, Transformer $transformer = null ):ResourceInterface
133
    {
134
        $transformer = $transformer ?: $model::transformer();
135
136
        if ( is_null( $transformer ) ) {
137
            return new FractalItem( $model, function () use ( $model ) {
138
                return $model->toArray();
139
            } );
140
        }
141
142
        return $this->transformData( $model, new $transformer( $model ), $model->getTable() );
143
    }
144
145
    /**
146
     * Transform a collection of Eloquent models.
@@ 152-164 (lines=13) @@
149
     * @param  Transformer|null $transformer
150
     * @return ResourceInterface
151
     */
152
    protected function transformCollection( Collection $collection, Transformer $transformer = null ):ResourceInterface
153
    {
154
        $model = $this->resolveModel( $collection );
155
        $transformer = $transformer ?: $model::transformer();
156
157
        if ( is_null( $transformer ) ) {
158
            return new FractalCollection( $collection, function () use ( $collection ) {
159
                return $collection->toArray();
160
            } );
161
        }
162
163
        return $this->transformData( $collection, new $transformer( $model ), $model->getTable() );
164
    }
165
166
    /**
167
     * Transform paginated data using Laravel's paginator.