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

Queue::__construct()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 7
Code Lines 5

Duplication

Lines 7
Ratio 100 %

Code Coverage

Tests 6
CRAP Score 1

Importance

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