BatchMapper   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 18
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 4
c 1
b 0
f 0
dl 0
loc 18
ccs 4
cts 4
cp 1
rs 10
wmc 2

2 Methods

Rating   Name   Duplication   Size   Complexity  
A map() 0 3 1
A __construct() 0 3 1
1
<?php
2
3
namespace mindplay\sql\framework\mappers;
4
5
use mindplay\sql\framework\Mapper;
6
use Traversable;
7
8
/**
9
 * Use this Mapper for quick, on-demand batch mapping - as an alternative to implementing an actual Mapper class.
10
 */
11
class BatchMapper implements Mapper
12
{
13
    /**
14
     * @var callable(array<array<string,mixed>>):iterable<array<string,mixed>>
15
     */
16
    private $mapper;
17
18
    /**
19
     * @param callable(array<array<string,mixed>>):iterable<array<string,mixed>> $mapper function (array $record_set): array
20
     */
21 1
    public function __construct(callable $mapper)
22
    {
23 1
        $this->mapper = $mapper;
24
    }
25
26 1
    public function map(array $record_set): array|Traversable
27
    {
28 1
        return ($this->mapper)($record_set);
29
    }
30
}
31