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 0%

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 0
cts 8
cp 0
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;
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