Code Duplication    Length = 14-17 lines in 2 locations

src/Relationships/BelongsTo.php 1 location

@@ 284-297 (lines=14) @@
281
     *
282
     * @return array
283
     */
284
    public function getForeignKeyValuePair($related)
285
    {
286
        $foreignKey = $this->getForeignKey();
287
288
        if ($related) {
289
            $wrapper = $this->factory->make($related);
290
291
            $relatedKey = $this->relatedMap->getKeyName();
292
293
            return [$foreignKey => $wrapper->getEntityAttribute($relatedKey)];
294
        } else {
295
            return [$foreignKey => null];
296
        }
297
    }
298
299
    /**
300
     * Get the fully qualified foreign key of the relationship.

src/Relationships/MorphTo.php 1 location

@@ 199-215 (lines=17) @@
196
     *
197
     * @return array
198
     */
199
    public function getForeignKeyValuePair($related)
200
    {
201
        $foreignKey = $this->getForeignKey();
202
203
        if ($related) {
204
            $wrapper = $this->factory->make($related);
205
206
            $relatedKey = $this->relatedMap->getKeyName();
207
208
            return [
209
                $foreignKey => $wrapper->getEntityAttribute($relatedKey),
210
                $this->morphType => $wrapper->getMap()->getMorphClass(),
211
            ];
212
        } else {
213
            return [$foreignKey => null];
214
        }
215
    }
216
217
    /**
218
     * Get the dictionary used by the relationship.