Completed
Push — master ( 49a516...79d061 )
by Marco
04:40
created

StackManager   A

Complexity

Total Complexity 5

Size/Duplication

Total Lines 37
Duplicated Lines 100 %

Coupling/Cohesion

Components 0
Dependencies 2

Test Coverage

Coverage 60%

Importance

Changes 0
Metric Value
wmc 5
lcom 0
cbo 2
dl 37
loc 37
ccs 6
cts 10
cp 0.6
rs 10
c 0
b 0
f 0

3 Methods

Rating   Name   Duplication   Size   Complexity  
A add() 5 5 1
A remove() 13 13 2
A get() 13 13 2

How to fix   Duplicated Code   

Duplicated Code

Duplicate code is one of the most pungent code smells. A rule that is often used is to re-structure code once it is duplicated in three or more places.

Common duplication problems, and corresponding solutions are:

1
<?php namespace Comodojo\SimpleCache\Components;
2
3
use \Comodojo\Cache\Components\AbstractStackManager;
4
use \Comodojo\SimpleCache\Interfaces\EnhancedSimpleCacheInterface;
5
use \Comodojo\Exception\SimpleCacheException;
6
use \Exception;
7
8
/**
9
 *
10
 * @package     Comodojo Spare Parts
11
 * @author      Marco Giovinazzi <[email protected]>
12
 * @license     MIT
13
 *
14
 * LICENSE:
15
 *
16
 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17
 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18
 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19
 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20
 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21
 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
22
 * THE SOFTWARE.
23
 */
24
25 View Code Duplication
class StackManager extends AbstractStackManager {
0 ignored issues
show
Duplication introduced by
This class seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
26
27 34
    public function add(EnhancedSimpleCacheInterface $provider, $weight) {
28
29 34
        return $this->genericAdd($provider, $weight);
30
31
    }
32
33 1
    public function remove($id) {
34
35
        try {
36
37 1
            return parent::remove($id);
38
39
        } catch (Exception $e) {
40
41
            throw new SimpleCacheException($e->getMessage());
42
43
        }
44
45
    }
46
47 1
    public function get($id) {
48
49
        try {
50
51 1
            return parent::get($id);
52
53
        } catch (Exception $e) {
54
55
            throw new SimpleCacheException($e->getMessage());
56
57
        }
58
59
    }
60
61
}
62