Completed
Push — 2.0 ( a51c1d...cacff6 )
by Marco
04:49
created

StackManager   A

Complexity

Total Complexity 5

Size/Duplication

Total Lines 37
Duplicated Lines 100 %

Coupling/Cohesion

Components 0
Dependencies 2

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
wmc 5
lcom 0
cbo 2
dl 37
loc 37
ccs 3
cts 3
cp 1
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 31
    public function add(EnhancedSimpleCacheInterface $provider, $weight) {
28
29 31
        parent::genericAdd($provider, $weight);
0 ignored issues
show
Comprehensibility Bug introduced by
It seems like you call parent on a different method (genericAdd() instead of add()). Are you sure this is correct? If so, you might want to change this to $this->genericAdd().

This check looks for a call to a parent method whose name is different than the method from which it is called.

Consider the following code:

class Daddy
{
    protected function getFirstName()
    {
        return "Eidur";
    }

    protected function getSurName()
    {
        return "Gudjohnsen";
    }
}

class Son
{
    public function getFirstName()
    {
        return parent::getSurname();
    }
}

The getFirstName() method in the Son calls the wrong method in the parent class.

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