ExtendMutator::__invoke()   A
last analyzed

Complexity

Conditions 3
Paths 3

Size

Total Lines 15
Code Lines 8

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 8
CRAP Score 3

Importance

Changes 2
Bugs 0 Features 0
Metric Value
c 2
b 0
f 0
dl 0
loc 15
ccs 8
cts 8
cp 1
rs 9.4285
cc 3
eloc 8
nc 3
nop 2
crap 3
1
<?php
2
3
namespace Underscore\Mutator;
4
5
use Underscore\Collection;
6
use Underscore\Mutator;
7
8
class ExtendMutator extends Mutator
9
{
10
    /**
11
     * Copy all of the properties in the source objects over to the destination object.
12
     *
13
     * It's in-order, so the last source will override properties of the same name
14
     * in previous arguments.
15
     *
16
     * @param Collection $collection
17
     * @param mixed      $source
18
     * @param ...
19
     * @return Collection
20
     */
21 1
    public function __invoke($collection, $source)
0 ignored issues
show
Unused Code introduced by
The parameter $source is not used and could be removed.

This check looks from parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
22
    {
23 1
        $sources = func_get_args();
24 1
        array_shift($sources); // remove $collection
25
26 1
        $collection = clone $collection;
27
28 1
        foreach ($sources as $source) {
29 1
            foreach ($source as $key => $value) {
30 1
                $collection[$key] = $value;
31
            }
32
        }
33
34 1
        return $collection;
35
    }
36
}
37