Completed
Push — develop ( a379bf )
by Nate
01:48
created

Collection::transform()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 14
Code Lines 8

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 6

Importance

Changes 0
Metric Value
dl 0
loc 14
ccs 0
cts 12
cp 0
rs 9.4285
c 0
b 0
f 0
cc 2
eloc 8
nc 2
nop 3
crap 6
1
<?php
2
3
/**
4
 * @author    Flipbox Factory
5
 * @copyright Copyright (c) 2017, Flipbox Digital
6
 * @link      https://github.com/flipbox/transform/releases/latest
7
 * @license   https://github.com/flipbox/transform/blob/master/LICENSE
8
 */
9
10
namespace Flipbox\Transform\Resources;
11
12
use Flipbox\Transform\Scope;
13
14
/**
15
 * @author Flipbox Factory <[email protected]>
16
 * @since 3.0.0
17
 */
18
class Collection extends AbstractResource
19
{
20
    /**
21
     * @inheritdoc
22
     */
23
    public function __invoke(Scope $scope, string $identifier = null, ...$params): array
24
    {
25
        $childScope = $scope->childScope($identifier);
26
27
        $items = [];
28
29
        foreach ($this->data as $data) {
30
            $items[] = $childScope->transform(
31
                $this->transformer,
32
                $data,
33
                $params
34
            );
35
        }
36
37
        return $items;
38
    }
39
}
40