Code Duplication    Length = 20-20 lines in 2 locations

src/services/traits/ModelByString.php 1 location

@@ 199-218 (lines=20) @@
196
     * @param BaseModel $model
197
     * @return static
198
     */
199
    protected function cacheByString(BaseModel $model)
200
    {
201
202
        $stringValue = $this->stringValue($model);
203
204
        if (null === $stringValue) {
205
            return $this;
206
        }
207
208
        // Check if already in cache
209
        if (!$this->isCachedByString($stringValue)) {
210
211
            // Cache it
212
            $this->_cacheByString[$stringValue] = $model;
213
214
        }
215
216
        return $this;
217
218
    }
219
220
    /**
221
     * @param Record $record

src/services/traits/ObjectByString.php 1 location

@@ 199-218 (lines=20) @@
196
     * @param BaseObject $model
197
     * @return static
198
     */
199
    protected function cacheByString(BaseObject $model)
200
    {
201
202
        $stringValue = $this->stringValue($model);
203
204
        if (null === $stringValue) {
205
            return $this;
206
        }
207
208
        // Check if already in cache
209
        if (!$this->isCachedByString($stringValue)) {
210
211
            // Cache it
212
            $this->_cacheByString[$stringValue] = $model;
213
214
        }
215
216
        return $this;
217
218
    }
219
220
    /**
221
     * @param Record $record