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

BatchMapper   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 20
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 0

Test Coverage

Coverage 100%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 2
c 1
b 0
f 0
lcom 1
cbo 0
dl 0
loc 20
ccs 5
cts 5
cp 1
rs 10

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 4 1
A map() 0 4 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