Code Duplication    Length = 9-12 lines in 2 locations

src/Relations/BelongsTo.php 1 location

@@ 58-69 (lines=12) @@
55
     * @param RecordCollection $collection
56
     * @return array
57
     */
58
    protected function buildDictionary(RecordCollection $collection)
59
    {
60
        if ($collection->isEmpty()) {
61
            return [];
62
        }
63
        $dictionary = [];
64
        foreach ($collection as $record) {
65
            $dictionary[$this->getDictionaryKey($record)] = $record;
66
        }
67
68
        return $dictionary;
69
    }
70
71
    /**
72
     * @param Record $record

src/Relations/HasOneOrMany.php 1 location

@@ 137-145 (lines=9) @@
134
     * @param RecordCollection $collection
135
     * @return array
136
     */
137
    protected function buildDictionary(RecordCollection $collection)
138
    {
139
        $dictionary = [];
140
        $primaryKey = $this->getDictionaryKey();
141
        foreach ($collection as $record) {
142
            $dictionary[$record->{$primaryKey}][] = $record;
143
        }
144
        return $dictionary;
145
    }
146
147
    /**
148
     * @return string