Code Duplication    Length = 18-18 lines in 5 locations

src/CachedBuilder.php 5 locations

@@ 139-156 (lines=18) @@
136
        }
137
    }
138
139
    public function avg($column)
140
    {
141
        $tags = [str_slug(get_class($this->model))];
142
        $key = str_slug(get_class($this->model)) ."-avg_{$column}";
143
144
        if ($this->isCaching()) {
145
            return parent::avg($column);
146
        }
147
148
        $cachingFlag = $this->setCachingFlag();
149
        $result = $this->cache($tags)
150
            ->rememberForever($key, function () use ($column) {
151
                return parent::avg($column);
152
            });
153
        $this->clearCachingFlag($cachingFlag);
154
155
        return $result;
156
    }
157
158
    public function count($columns = ['*'])
159
    {
@@ 158-175 (lines=18) @@
155
        return $result;
156
    }
157
158
    public function count($columns = ['*'])
159
    {
160
        $tags = [str_slug(get_class($this->model))];
161
        $key = str_slug(get_class($this->model)) ."-count";
162
163
        if ($this->isCaching()) {
164
            return parent::count($columns);
165
        }
166
167
        $cachingFlag = $this->setCachingFlag();
168
        $result = $this->cache($tags)
169
            ->rememberForever($key, function () use ($columns) {
170
                return parent::count($columns);
171
            });
172
        $this->clearCachingFlag($cachingFlag);
173
174
        return $result;
175
    }
176
177
    public function cursor()
178
    {
@@ 256-273 (lines=18) @@
253
        return $result;
254
    }
255
256
    public function max($column)
257
    {
258
        $tags = [str_slug(get_class($this->model))];
259
        $key = str_slug(get_class($this->model)) ."-max_{$column}";
260
261
        if ($this->isCaching()) {
262
            return parent::max($column);
263
        }
264
265
        $cachingFlag = $this->setCachingFlag();
266
        $result = $this->cache($tags)
267
            ->rememberForever($key, function () use ($column) {
268
                return parent::max($column);
269
            });
270
        $this->clearCachingFlag($cachingFlag);
271
272
        return $result;
273
    }
274
275
    public function min($column)
276
    {
@@ 275-292 (lines=18) @@
272
        return $result;
273
    }
274
275
    public function min($column)
276
    {
277
        $tags = [str_slug(get_class($this->model))];
278
        $key = str_slug(get_class($this->model)) ."-min_{$column}";
279
280
        if ($this->isCaching()) {
281
            return parent::min($column);
282
        }
283
284
        $cachingFlag = $this->setCachingFlag();
285
        $result = $this->cache($tags)
286
            ->rememberForever($key, function () use ($column) {
287
                return parent::min($column);
288
            });
289
        $this->clearCachingFlag($cachingFlag);
290
291
        return $result;
292
    }
293
294
    public function pluck($column, $key = null)
295
    {
@@ 317-334 (lines=18) @@
314
        return $result;
315
    }
316
317
    public function sum($column)
318
    {
319
        $tags = [str_slug(get_class($this->model))];
320
        $key = str_slug(get_class($this->model)) ."-sum_{$column}";
321
322
        if ($this->isCaching()) {
323
            return parent::sum($column);
324
        }
325
326
        $cachingFlag = $this->setCachingFlag();
327
        $result = $this->cache($tags)
328
            ->rememberForever($key, function () use ($column) {
329
                return parent::sum($column);
330
            });
331
        $this->clearCachingFlag($cachingFlag);
332
333
        return $result;
334
    }
335
}
336