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

Mapping::map()   A

Complexity

Conditions 3
Paths 3

Size

Total Lines 11
Code Lines 6

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 9
CRAP Score 3

Importance

Changes 1
Bugs 0 Features 1
Metric Value
c 1
b 0
f 1
dl 0
loc 11
ccs 9
cts 9
cp 1
rs 9.4285
cc 3
eloc 6
nc 3
nop 3
crap 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