Mapping::map()   A
last analyzed

Complexity

Conditions 3
Paths 3

Size

Total Lines 8
Code Lines 5

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 6
CRAP Score 3

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 3
eloc 5
c 1
b 0
f 0
nc 3
nop 3
dl 0
loc 8
ccs 6
cts 6
cp 1
crap 3
rs 10
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Genkgo\Camt\Decoder\Factory\DTO\Behavior;
6
7
use SimpleXMLElement;
8
9
trait Mapping
10
{
11
    /**
12
     * @param string[][] $mapping
13
     */
14 23
    public static function map(object $object, SimpleXMLElement $xml, array $mapping): void
15
    {
16 23
        foreach ($mapping as $line) {
17 23
            $setter = $line['setter'];
18 23
            $xmlValue = $line['value'];
19
20 23
            if (isset($xml->$xmlValue)) {
21 23
                $object->$setter((string) $xml->$xmlValue);
22
            }
23
        }
24 23
    }
25
}
26