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

CrawledInfoMapper::mapQuote()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 7
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 4
CRAP Score 2

Importance

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