Deque::__construct()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 7
Code Lines 5

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 6
CRAP Score 1

Importance

Changes 0
Metric Value
dl 0
loc 7
ccs 6
cts 6
cp 1
rs 9.4285
c 0
b 0
f 0
cc 1
eloc 5
nc 1
nop 3
crap 1
1
<?php
2
namespace GenericCollections;
3
4
use GenericCollections\Abstracts\AbstractDeque;
5
use GenericCollections\Traits\ElementTypeProperty;
6
use GenericCollections\Traits\OptionsProperty;
7
use GenericCollections\Utils\TypeProperty;
8
9
/**
10
 * Generic double ended queue implementation
11
 *
12
 * This class has a FIFO behavior on add, offer, element, peek, remove & poll methods
13
 *
14
 * Options:
15
 * - Defaults: not allow nulls, allow duplicates, identical comparisons
16
 *
17
 * It is not recommended to allow nulls since several methods
18
 * (element, pollFirst, pollLast, poll, peekFirst, peekLast and peek)
19
 * returns null if not found or empty
20
 *
21
 * It is not recommended to set unique values option, this will search inside the
22
 * container on every insert and it could be expensive on large containers
23
 *
24
 * @package GenericCollections
25
 */
26
class Deque extends AbstractDeque
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...
27
{
28
    use ElementTypeProperty;
29
    use OptionsProperty;
30
31
    /**
32
     * @param string $elementType
33
     * @param array $elements
34
     * @param int $options
35
     */
36 65
    public function __construct($elementType, array $elements = [], $options = 0)
37
    {
38 65
        $this->options = new Options($options);
39 65
        $this->elementType = new TypeProperty($elementType, $this->optionAllowNullMembers());
40 65
        $this->createStorageObject();
41 65
        $this->addAll($elements);
42 65
    }
43
}
44