ObjectHelper::configure()   A
last analyzed

Complexity

Conditions 4
Paths 4

Size

Total Lines 11

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 3
CRAP Score 7.9062

Importance

Changes 0
Metric Value
dl 0
loc 11
ccs 3
cts 8
cp 0.375
rs 9.9
c 0
b 0
f 0
cc 4
nc 4
nop 2
crap 7.9062
1
<?php
2
3
/**
4
 * @author    Flipbox Factory
5
 * @copyright Copyright (c) 2017, Flipbox Digital
6
 * @link      https://github.com/flipbox/transform/releases/latest
7
 * @license   https://github.com/flipbox/transform/blob/master/LICENSE
8
 */
9
10
namespace Flipbox\Transform\Helpers;
11
12
/**
13
 * @author Flipbox Factory <[email protected]>
14
 * @since 3.0.0
15
 */
16
class ObjectHelper
17
{
18
    /**
19
     * @param $object
20
     * @param array $config
21
     */
22 18
    public static function configure($object, array $config = [])
23
    {
24 18
        foreach ($config as $key => $val) {
25
            $setter = 'set' . $key;
26
            if (method_exists($object, $setter)) {
27
                $object->$setter($val);
28
            } elseif (property_exists($object, $key)) {
29
                $object->$key = $val;
30
            }
31
        }
32 18
    }
33
}
34