Completed
Pull Request — master (#10)
by
unknown
25:40
created

AbstractCollectionArray::setAll()   B

Complexity

Conditions 5
Paths 4

Size

Total Lines 15
Code Lines 8

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 30

Importance

Changes 2
Bugs 0 Features 0
Metric Value
c 2
b 0
f 0
dl 0
loc 15
ccs 0
cts 8
cp 0
rs 8.8571
cc 5
eloc 8
nc 4
nop 1
crap 30
1
<?php
0 ignored issues
show
Coding Style Compatibility introduced by
For compatibility and reusability of your code, PSR1 recommends that a file should introduce either new symbols (like classes, functions, etc.) or have side-effects (like outputting something, or including other files), but not both at the same time. The first symbol is defined on line 20 and the first side effect is on line 9.

The PSR-1: Basic Coding Standard recommends that a file should either introduce new symbols, that is classes, functions, constants or similar, or have side effects. Side effects are anything that executes logic, like for example printing output, changing ini settings or writing to a file.

The idea behind this recommendation is that merely auto-loading a class should not change the state of an application. It also promotes a cleaner style of programming and makes your code less prone to errors, because the logic is not spread out all over the place.

To learn more about the PSR-1, please see the PHP-FIG site on the PSR-1.

Loading history...
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
0 ignored issues
show
Bug introduced by
Possible parse error: class missing opening or closing brace
Loading history...
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) {
0 ignored issues
show
Coding Style introduced by
Line indented incorrectly; expected 4 spaces, found 8
Loading history...
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
}
0 ignored issues
show
Coding Style introduced by
It seems like the identation of this line is off (expected at least 4 spaces, but found 0).
Loading history...
46