Completed
Push — 2.0 ( b5e900...ba9d42 )
by Marco
05:08
created

StackManager   A

Complexity

Total Complexity 5

Size/Duplication

Total Lines 37
Duplicated Lines 100 %

Coupling/Cohesion

Components 0
Dependencies 2

Test Coverage

Coverage 27.27%

Importance

Changes 0
Metric Value
wmc 5
lcom 0
cbo 2
dl 37
loc 37
ccs 3
cts 11
cp 0.2727
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\Cache\Components;
2
3
use \Comodojo\Cache\Interfaces\EnhancedCacheItemPoolInterface;
4
use \Comodojo\Exception\CacheException;
5
use \Exception;
6
7
/**
8
 *
9
 * @package     Comodojo Spare Parts
10
 * @author      Marco Giovinazzi <[email protected]>
11
 * @license     MIT
12
 *
13
 * LICENSE:
14
 *
15
 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
 * THE SOFTWARE.
22
 */
23
24 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...
25
26 41
    public function add(EnhancedCacheItemPoolInterface $provider, $weight) {
27
28 41
        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...
29
30 41
    }
31
32
    public function remove($id) {
33
34
        try {
35
36
            return parent::remove($id);
37
38
        } catch (Exception $e) {
39
40
            throw new CacheException($e->getMessage());
41
42
        }
43
44
    }
45
46
    public function get($id) {
47
48
        try {
49
50
            return parent::get($id);
51
52
        } catch (Exception $e) {
53
54
            throw new CacheException($e->getMessage());
55
56
        }
57
58
    }
59
60
}
61