Passed
Push — master ( c0f32c...e879f4 )
by Chema
04:17 queued 41s
created

CrawledInfoMapper::__construct()   A

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 0
Metric Value
eloc 1
c 0
b 0
f 0
dl 0
loc 3
ccs 2
cts 2
cp 1
rs 10
cc 1
nc 1
nop 1
crap 1
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Chemaclass\StockTicker\Domain\Crawler\Mapper;
6
7
use Chemaclass\StockTicker\Domain\WriteModel\Quote;
8
9
final class CrawledInfoMapper implements CrawledInfoMapperInterface
10
{
11
    /** @var null|callable */
12
    private $mapper;
13
14 6
    public function __construct(?callable $mapper = null)
15
    {
16 6
        $this->mapper = $mapper;
17 6
    }
18
19 5
    public function mapQuote(array $info): Quote
20
    {
21 5
        if ($this->mapper) {
22 5
            $info = ($this->mapper)($info);
23
        }
24
25 5
        return (new Quote())->fromArray($info);
26
    }
27
}
28