Completed
Pull Request — master (#5)
by Carlos C
13:10
created

Stack   A

Complexity

Total Complexity 1

Size/Duplication

Total Lines 18
Duplicated Lines 100 %

Coupling/Cohesion

Components 0
Dependencies 5

Test Coverage

Coverage 100%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 1
c 1
b 0
f 0
lcom 0
cbo 5
dl 18
loc 18
ccs 6
cts 6
cp 1
rs 10

1 Method

Rating   Name   Duplication   Size   Complexity  
A __construct() 7 7 1

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 GenericCollections;
2
3
use GenericCollections\Abstracts\AbstractStack;
4
use GenericCollections\Interfaces\StackInterface;
5
use GenericCollections\Traits\ElementTypeProperty;
6
use GenericCollections\Traits\OptionsProperty;
7
use GenericCollections\Utils\TypeProperty;
8
9
/**
10
 * Generic Stack implementation (LIFO behavior)
11
 *
12
 * Options:
13
 * - Defaults: not allow nulls, allow duplicates, identical comparisons
14
 *
15
 * It is not recommended to allow nulls since several methods
16
 * (element, peek, poll)
17
 * returns null if not found or empty
18
 *
19
 * It is not recommended to set unique values option, this will search inside the
20
 * container on every insert and it could be expensive on large containers
21
 *
22
 * @package GenericCollections
23
 */
24 View Code Duplication
class Stack extends AbstractStack implements StackInterface
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
    use ElementTypeProperty;
27
    use OptionsProperty;
28
29
    /**
30
     * @param string $elementType
31
     * @param array $elements
32
     * @param int $options
33
     */
34 24
    public function __construct($elementType, array $elements = [], $options = 0)
35
    {
36 24
        $this->options = new Options($options);
37 24
        $this->elementType = new TypeProperty($elementType, $this->optionAllowNullMembers());
38 24
        $this->createStorageObject();
39 24
        $this->addAll($elements);
40 24
    }
41
}
42