Completed
Push — master ( d52ee7...e7842c )
by Alexandr
03:54
created

ConfigAwareTrait   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 22
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 0

Test Coverage

Coverage 100%

Importance

Changes 3
Bugs 0 Features 0
Metric Value
wmc 4
c 3
b 0
f 0
lcom 1
cbo 0
dl 0
loc 22
rs 10
ccs 6
cts 6
cp 1

3 Methods

Rating   Name   Duplication   Size   Complexity  
A getConfig() 0 4 1
A getConfigValue() 0 4 2
A getDescription() 0 4 1
1
<?php
2
/*
3
 * This file is a part of GraphQL project.
4
 *
5
 * @author Alexandr Viniychuk <[email protected]>
6
 * created: 2:02 PM 5/13/16
7
 */
8
9
namespace Youshido\GraphQL\Config\Traits;
10
11
12
use Youshido\GraphQL\Config\AbstractConfig;
13
use Youshido\GraphQL\Config\Field\FieldConfig;
14
use Youshido\GraphQL\Config\Field\InputFieldConfig;
15
use Youshido\GraphQL\Config\Object\ObjectTypeConfig;
16
17
trait ConfigAwareTrait
18
{
19
20
    /** @var AbstractConfig|ObjectTypeConfig|FieldConfig|InputFieldConfig */
21
    protected $config;
22
23 30
    public function getConfig()
24
    {
25 30
        return $this->config;
26
    }
27
28 53
    protected function getConfigValue($key, $defaultValue = null)
29
    {
30 53
        return !empty($this->config) ? $this->config->get($key, $defaultValue) : $defaultValue;
31
    }
32
33 9
    public function getDescription()
34
    {
35 9
        return $this->getConfigValue('description');
36
    }
37
38
}
39