Completed
Push — master ( e86954...7cbcb1 )
by Ítalo
02:48
created

AbstractCollectionArray::clear()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 6
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 3
CRAP Score 1

Importance

Changes 4
Bugs 0 Features 1
Metric Value
c 4
b 0
f 1
dl 0
loc 6
ccs 3
cts 3
cp 1
rs 9.4286
cc 1
eloc 3
nc 1
nop 0
crap 1
1
<?php
2
3
// Copyright (c) Lellys Informática. All rights reserved. See License.txt in the project root for license information.
4
namespace Collections;
5
6
/**
7
 * Provides the abstract base class for a strongly typed collection.
8
 */
9
abstract class AbstractCollectionArray extends AbstractConstCollectionArray implements
10
    CollectionInterface,
11
    IndexAccessInterface,
12
    ConstIndexAccessInterface,
13
    CollectionConvertableInterface,
14
    \Serializable,
15
    \JsonSerializable
16
{
17
    /**
18
     * {@inheritdoc}
19
     */
20
    public function setAll($items)
21
    {
22
        if (!is_array($items) && !$items instanceof \Traversable) {
23
            throw new \InvalidArgumentException('Parameter must be an array or an instance of Traversable');
24
        }
25
26
        foreach ($items as $key => $item) {
27
            if (is_array($item)) {
28
                $item = new static($item);
29
            }
30
            $this->set($key, $item);
31
        }
32
33
        return $this;
34
    }
35
36
    /**
37
     * {@inheritdoc}
38
     */
39 1
    public function clear()
40
    {
41 1
        $this->container = [];
42
43 1
        return $this;
44
    }
45
}
46