ObjectHelper   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 18
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 0

Test Coverage

Coverage 37.5%

Importance

Changes 0
Metric Value
wmc 4
lcom 0
cbo 0
dl 0
loc 18
ccs 3
cts 8
cp 0.375
rs 10
c 0
b 0
f 0

1 Method

Rating   Name   Duplication   Size   Complexity  
A configure() 0 11 4
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