Set   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 17
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 2

Test Coverage

Coverage 0%

Importance

Changes 0
Metric Value
wmc 2
c 0
b 0
f 0
lcom 0
cbo 2
dl 0
loc 17
ccs 0
cts 9
cp 0
rs 10

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 4 1
A getIterator() 0 4 1
1
<?php
2
3
namespace Collections;
4
5
use Collections\Iterator\SetIterator;
6
use Collections\Traits\SetLikeTrait;
7
8
/**
9
 * Set is an ordered set-style collection.
10
 *
11
 * Like all objects in PHP, Sets have reference-like semantics. When a caller
12
 * passes a Set to a callee, the callee can modify the Set and the caller will
13
 * see the changes. Sets do not have "copy-on-write" semantics.
14
 *
15
 * Sets preserve insertion order of the elements. When iterating over a Set,
16
 * the elements appear in the order they were inserted. Also, Sets do not
17
 * automagically convert integer-like strings (ex. "123") into integers.
18
 *
19
 * Sets only support integer values and string values. If a value of a
20
 * different type is used, an exception will be thrown.
21
 *
22
 * In general, Sets do not support "$c[$k]" style syntax. Adding an element
23
 * using "$c[] = .." syntax is supported.
24
 *
25
 * Set do not support iteration while elements are being added or removed.
26
 * When an element is added or removed, all iterators that point to the Set
27
 * shall be considered invalid.
28
 *
29
 * Sets do not support taking elements by reference. If binding assignment (=&)
30
 * is used when adding a new element to a Set (ex. "$c[] =& ..."), or if a Set
31
 * is used with foreach by reference, an exception will be thrown.
32
 */
33
class Set implements SetInterface, \ArrayAccess, \JsonSerializable, \Serializable
34
{
35
    use SetLikeTrait;
36
37
    public function __construct($array = null)
38
    {
39
        $this->init($array);
40
    }
41
42
    /**
43
     * @inheritDoc
44
     */
45
    public function getIterator()
46
    {
47
        return new SetIterator($this->container);
48
    }
49
}
50