Completed
Pull Request — master (#27)
by Yann
02:57
created

Mapping   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 18
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 0

Test Coverage

Coverage 100%

Importance

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

1 Method

Rating   Name   Duplication   Size   Complexity  
A map() 0 11 3
1
<?php
2
3
namespace Genkgo\Camt\Decoder\Factory\DTO\Behavior;
4
5
use SimpleXMLElement;
6
7
trait Mapping
8
{
9
    /**
10
     * @param object $object
11
     * @param SimpleXMLElement $xml
12
     */
13 17
    public static function map($object, SimpleXMLElement $xml, array $mapping)
14
    {
15 17
        foreach ($mapping as $line) {
16 17
            $setter   = $line[0];
17 17
            $xmlValue = $line[1];
18
19 17
            if (isset($xml->$xmlValue)) {
20 17
                $object->$setter((string) $xml->$xmlValue);
21 17
            }
22 17
        }
23 17
    }
24
}
25