Code Duplication    Length = 11-11 lines in 7 locations

src/CachedBuilder.php 7 locations

@@ 15-25 (lines=11) @@
12
13
    protected $isCachable = true;
14
15
    public function avg($column)
16
    {
17
        if (! $this->isCachable) {
18
            return parent::avg($column);
19
        }
20
21
        return $this->cache($this->makeCacheTags())
22
            ->rememberForever($this->makeCacheKey() . "-avg_{$column}", function () use ($column) {
23
                return parent::avg($column);
24
            });
25
    }
26
27
    public function count($columns = ['*'])
28
    {
@@ 27-37 (lines=11) @@
24
            });
25
    }
26
27
    public function count($columns = ['*'])
28
    {
29
        if (! $this->isCachable) {
30
            return parent::count($columns);
31
        }
32
33
        return $this->cache($this->makeCacheTags())
34
            ->rememberForever($this->makeCacheKey() . "-count", function () use ($columns) {
35
                return parent::count($columns);
36
            });
37
    }
38
39
    public function cursor()
40
    {
@@ 81-91 (lines=11) @@
78
            });
79
    }
80
81
    public function first($columns = ['*'])
82
    {
83
        if (! $this->isCachable) {
84
            return parent::first($columns);
85
        }
86
87
        return $this->cache($this->makeCacheTags())
88
            ->rememberForever($this->makeCacheKey($columns) . '-first', function () use ($columns) {
89
                return parent::first($columns);
90
            });
91
    }
92
93
    public function get($columns = ['*'])
94
    {
@@ 93-103 (lines=11) @@
90
            });
91
    }
92
93
    public function get($columns = ['*'])
94
    {
95
        if (! $this->isCachable) {
96
            return parent::get($columns);
97
        }
98
99
        return $this->cache($this->makeCacheTags())
100
            ->rememberForever($this->makeCacheKey($columns), function () use ($columns) {
101
                return parent::get($columns);
102
            });
103
    }
104
105
    public function max($column)
106
    {
@@ 105-115 (lines=11) @@
102
            });
103
    }
104
105
    public function max($column)
106
    {
107
        if (! $this->isCachable) {
108
            return parent::max($column);
109
        }
110
111
        return $this->cache($this->makeCacheTags())
112
            ->rememberForever($this->makeCacheKey() . "-max_{$column}", function () use ($column) {
113
                return parent::max($column);
114
            });
115
    }
116
117
    public function min($column)
118
    {
@@ 117-127 (lines=11) @@
114
            });
115
    }
116
117
    public function min($column)
118
    {
119
        if (! $this->isCachable) {
120
            return parent::min($column);
121
        }
122
123
        return $this->cache($this->makeCacheTags())
124
            ->rememberForever($this->makeCacheKey() . "-min_{$column}", function () use ($column) {
125
                return parent::min($column);
126
            });
127
    }
128
129
    public function pluck($column, $key = null)
130
    {
@@ 147-157 (lines=11) @@
144
            });
145
    }
146
147
    public function sum($column)
148
    {
149
        if (! $this->isCachable) {
150
            return parent::sum($column);
151
        }
152
153
        return $this->cache($this->makeCacheTags())
154
            ->rememberForever($this->makeCacheKey() . "-sum_{$column}", function () use ($column) {
155
                return parent::sum($column);
156
            });
157
    }
158
159
    protected function makeCacheKey(array $columns = ['*'], $idColumn = null) : string
160
    {