EmbeddedMapping   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 37
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 3

Test Coverage

Coverage 100%

Importance

Changes 1
Bugs 0 Features 1
Metric Value
c 1
b 0
f 1
dl 0
loc 37
wmc 3
lcom 1
cbo 3
ccs 13
cts 13
cp 1
rs 10

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 5 1
A map() 0 14 2
1
<?php
2
3
namespace Cascade\Mapper\Mapping;
4
5
use Cascade\Mapper\Field\Reference\ReferenceInterface;
6
use Cascade\Mapper\Map\MapInterface;
7
8
class EmbeddedMapping implements MappingInterface
9
{
10
    /**
11
     * @var ReferenceInterface
12
     */
13
    private $sourceReference;
14
15
    /**
16
     * @var MapInterface
17
     */
18
    private $map;
19
20
    /**
21
     * @param ReferenceInterface $sourceReference
22
     * @param MapInterface $map
23
     */
24 3
    public function __construct(ReferenceInterface $sourceReference, MapInterface $map)
25
    {
26 3
        $this->sourceReference = $sourceReference;
27 3
        $this->map = $map;
28 3
    }
29
30 1
    public function map($destination, $source)
31
    {
32 1
        $sourceReference = $this->sourceReference;
33 1
        $mappings = $this->map->getMappings();
34
35 1
        $embeddedValues = $sourceReference->getValue($source);
36
37 1
        $newDestination = $destination;
38 1
        foreach ($mappings as $mapping) {
39 1
            $newDestination = $mapping->map($newDestination, $embeddedValues);
40 1
        }
41
42 1
        return $newDestination;
43
    }
44
}
45