Completed
Push — master ( 6ea5e4...20d81d )
by Rasmus
04:22
created

BatchMapper::map()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 4
ccs 0
cts 4
cp 0
rs 10
cc 1
eloc 2
nc 1
nop 1
crap 2
1
<?php
2
3
namespace mindplay\sql\framework;
4
5
/**
6
 * Use this Mapper for quick, on-demand batch mapping - as an alternative to implementing an actual Mapper class.
7
 */
8
class BatchMapper implements Mapper
9
{
10
    /**
11
     * @var callable
12
     */
13
    private $mapper;
14
15
    /**
16
     * @param callable $mapper function (array $record_set) : array
17
     */
18
    public function __construct(callable $mapper)
19
    {
20
        $this->mapper = $mapper;
21
    }
22
23
    public function map(array $record_set)
24
    {
25
        return call_user_func($this->mapper, $record_set);
26
    }
27
}
28