Completed
Branch develop (781062)
by Nate
02:36
created

ObjectHelper::configure()   A

Complexity

Conditions 4
Paths 4

Size

Total Lines 11
Code Lines 7

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 20

Importance

Changes 0
Metric Value
dl 0
loc 11
ccs 0
cts 11
cp 0
rs 9.2
c 0
b 0
f 0
cc 4
eloc 7
nc 4
nop 2
crap 20
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 1.0.0
15
 */
16
class ObjectHelper
17
{
18
    /**
19
     * @param $object
20
     * @param array $config
21
     */
22
    public static function configure($object, array $config = [])
23
    {
24
        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
    }
33
}
34