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

BatchMapper::__construct()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 3
CRAP Score 1

Importance

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