BatchMapper::map()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 1

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 1
c 1
b 0
f 0
nc 1
nop 1
dl 0
loc 3
ccs 2
cts 2
cp 1
crap 1
rs 10
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