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

Set::__construct()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 8
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 6
CRAP Score 2

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 8
ccs 6
cts 6
cp 1
rs 9.4285
cc 2
eloc 4
nc 2
nop 3
crap 2
1
<?php namespace GenericCollections;
2
3
/**
4
 * Generic set implementation
5
 *
6
 * A set is the same as a collection but can't contain duplicated values
7
 *
8
 * Options:
9
 * - Defaults: not allow nulls, identical comparisons
10
 * - It is not possible to allow duplicates, use a Collection instead
11
 * - If allow null elements is enabled only 1 element can be null
12
 *
13
 * @package GenericCollections
14
 */
15
16
class Set extends Collection
17
{
18
19
    /**
20
     * @param string $elementType
21
     * @param array $elements
22
     * @param int $options Options::COMPARISON_EQUAL
23
     */
24 9
    public function __construct($elementType, array $elements = [], $options = Options::UNIQUE_VALUES)
25
    {
26
        // force Options::UNIQUE_VALUES
27 9
        if (is_int($options)) {
28 9
            $options = $options | Options::UNIQUE_VALUES;
29 9
        }
30 9
        parent::__construct($elementType, $elements, $options);
31 9
    }
32
}
33