Completed
Pull Request — master (#29)
by
unknown
06:43
created

MutationConfigObject   A

Complexity

Total Complexity 6

Size/Duplication

Total Lines 32
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 1

Test Coverage

Coverage 63.64%

Importance

Changes 0
Metric Value
wmc 6
lcom 0
cbo 1
dl 0
loc 32
ccs 7
cts 11
cp 0.6364
rs 10
c 0
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 12 4
A __get() 0 8 2
1
<?php
2
3
namespace Softonic\GraphQL\Config;
4
5
use Softonic\GraphQL\Traits\JsonPathAccessor;
6
7
class MutationConfigObject
8
{
9
    use JsonPathAccessor;
10
11
    public $type;
12
13
    public $linksTo;
14
15
    public $children = [];
16
17 50
    public function __construct(array $config = [])
18
    {
19 50
        foreach ($config as $key => $value) {
20 50
            if ($key === 'children') {
21 50
                foreach ($value as $propertyName => $property) {
22 50
                    $this->children[$propertyName] = new static($property);
23
                }
24
            } else {
25 50
                $this->{$key} = $value;
26
            }
27
        }
28 50
    }
29
30
    public function __get($key)
31
    {
32
        if (property_exists(static::class, $key)) {
33
            return $this->{$key};
34
        }
35
36
        return $this->children[$key];
37
    }
38
}
39