Set::__construct()   A
last analyzed

Complexity

Conditions 2
Paths 2

Size

Total Lines 8
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 5
CRAP Score 2

Importance

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