MappingValueConverter   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 27
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 1

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
wmc 3
lcom 0
cbo 1
dl 0
loc 27
rs 10
c 0
b 0
f 0
ccs 9
cts 9
cp 1

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 4 1
A __invoke() 0 11 2
1
<?php
2
3
namespace Ddeboer\DataImport\ValueConverter;
4
5
use Ddeboer\DataImport\Exception\UnexpectedValueException;
6
7
/**
8
 * @author Grégoire Paris
9
 */
10
class MappingValueConverter
11
{
12
    /**
13
     * @var array
14
     */
15
    private $mapping = [];
16
17
    /**
18
     * @param array $mapping
19
     */
20 1
    public function __construct(array $mapping)
21
    {
22 1
        $this->mapping = $mapping;
23 1
    }
24
25 1
    public function __invoke($input)
26
    {
27 1
        if (!isset($this->mapping[$input])) {
28 1
            throw new UnexpectedValueException(sprintf(
29 1
                'Cannot find mapping for value "%s"',
30
                $input
31 1
            ));
32
        }
33
34 1
        return $this->mapping[$input];
35
    }
36
}
37