FromInitializer::__invoke()   A
last analyzed

Complexity

Conditions 2
Paths 2

Size

Total Lines 9
Code Lines 6

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 5
CRAP Score 2

Importance

Changes 3
Bugs 0 Features 0
Metric Value
c 3
b 0
f 0
dl 0
loc 9
ccs 5
cts 5
cp 1
rs 9.6666
cc 2
eloc 6
nc 2
nop 1
crap 2
1
<?php
2
3
namespace Underscore\Initializer;
4
5
use Underscore\Collection;
6
use Underscore\Initializer;
7
use Underscore\Underscore;
8
9
class FromInitializer extends Initializer
10
{
11
    /**
12
     * Initializes Underscore object and sets argument as internal collection
13
     *
14
     * @param mixed $item
15
     * @return Underscore
16
     */
17 47
    public function __invoke($item)
18
    {
19 47
        if ($item instanceof Collection) {
20 1
            $item = clone $item;
21
        } else {
22 46
            $item = new Collection($item);
23
        }
24 47
        return new Underscore($item);
25
    }
26
}
27