Completed
Push — master ( 198b3f...28f717 )
by Nate
02:18
created

Collection::transform()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 17
Code Lines 7

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 17
rs 9.4285
c 0
b 0
f 0
cc 2
eloc 7
nc 2
nop 2
1
<?php
2
3
/**
4
 * @package   Transform
5
 * @author    Flipbox Factory
6
 * @copyright Copyright (c) 2017, Flipbox Digital
7
 * @link      https://github.com/flipbox/transform/releases/latest
8
 * @license   https://github.com/flipbox/transform/blob/master/LICENSE
9
 */
10
11
namespace flipbox\transform\resources;
12
13
use ArrayIterator;
14
15
/**
16
 * @package flipbox\transform\resources
17
 * @author Flipbox Factory <[email protected]>
18
 * @since 1.0.0
19
 *
20
 * @property array|ArrayIterator $data
21
 */
22
class Collection extends Item
23
{
24
25
    /**
26
     * @param callable $transformer
27
     * @param $data
28
     * @return array|null
29
     */
30
    public function transform(callable $transformer, $data)
31
    {
32
33
        $items = [];
34
35
        foreach ($data as $item) {
36
37
            $items[] = parent::transform(
38
                $transformer,
39
                $item
40
            );
41
42
        }
43
44
        return $items;
45
46
    }
47
48
}
49