Completed
Push — master ( 97a535...5d395b )
by Carlos C
14:54 queued 02:21
created

Set::add()   A

Complexity

Conditions 3
Paths 3

Size

Total Lines 11
Code Lines 6

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 6
CRAP Score 3

Importance

Changes 1
Bugs 0 Features 1
Metric Value
c 1
b 0
f 1
dl 0
loc 11
ccs 6
cts 6
cp 1
rs 9.4285
cc 3
eloc 6
nc 3
nop 1
crap 3
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