Code Duplication    Length = 8-11 lines in 4 locations

src/Cache/Driver/Shm.php 4 locations

@@ 133-140 (lines=8) @@
130
     * @return mixed|null
131
     * @throws Exception
132
     */
133
    public function get($key)
134
    {
135
        if (!$this->isAvailable()) {
136
            throw new Exception('SHM is not available');
137
        }
138
        $key = $this->secureName($key);
139
        return ($this->has($key)) ? $this->shmGetVar($this->getShm(), $key) : null;
140
    }
141
142
    /**
143
     * @return bool
@@ 157-164 (lines=8) @@
154
     * @return bool
155
     * @throws Exception
156
     */
157
    public function has($key)
158
    {
159
        if (!$this->isAvailable()) {
160
            throw new Exception('SHM is not available');
161
        }
162
        $key = $this->secureName($key);
163
        return $this->shmHasVar($this->getShm(), $key);
164
    }
165
166
    /**
167
     * Remove a stored key if exists
@@ 172-182 (lines=11) @@
169
     * @return $this
170
     * @throws Exception
171
     */
172
    public function remove($key)
173
    {
174
        if (!$this->isAvailable()) {
175
            throw new Exception('SHM is not available');
176
        }
177
        $key = $this->secureName($key);
178
        if ($this->has($key) && !$this->shmRemoveVar($this->getShm(), $key)) {
179
            throw new Exception('Unable to delete key from cache Shm');
180
        }
181
        return $this;
182
    }
183
184
    /**
185
     * @param resource $shmResource
@@ 202-212 (lines=11) @@
199
     * @throws Exception
200
     * @return $this
201
     */
202
    public function set($key, $value)
203
    {
204
        if (!$this->isAvailable()) {
205
            throw new Exception('SHM is not available');
206
        }
207
        $key = $this->secureName($key);
208
        if (!$this->shmPutVar($this->getShm(), $key, $value)) {
209
            throw new Exception('Unable to define key into cache Shm');
210
        }
211
        return $this;
212
    }
213
214
    /**
215
     * @param resource $shmResource