Completed
Push — master ( 9d56e7...43a437 )
by Prabath
10:19 queued 08:51
created

ApplyConfig   A

Complexity

Total Complexity 5

Size/Duplication

Total Lines 18
Duplicated Lines 0 %

Test Coverage

Coverage 85.71%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 7
c 1
b 0
f 0
dl 0
loc 18
ccs 6
cts 7
cp 0.8571
rs 10
wmc 5

1 Method

Rating   Name   Duplication   Size   Complexity  
A apply_config() 0 10 5
1
<?php
2
3
4
namespace databoxtech\multisocial;
5
6
use databoxtech\multisocial\exception\ConfigRequiredException;
7
8
trait ApplyConfig
9
{
10
11
    /**
12
     * @param array $config
13
     * @param array $required required configurations
14
     * @throws ConfigRequiredException
15
     */
16 2
    public function apply_config($config, $required = []){
17 2
        foreach ($config as $key => $value){
18 2
            if(property_exists($this, $key)){
19 2
                $this->{$key} = $value;
20
            }
21
        }
22
23 2
        foreach ($required as $conf){
24 2
            if(!isset($config[$conf])){
25
                throw new ConfigRequiredException($conf);
26
            }
27
        }
28
    }
29
}