Completed
Push — master ( f8702a...461e07 )
by Alexandr
04:08
created

Field   A

Complexity

Total Complexity 5

Size/Duplication

Total Lines 36
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 2

Test Coverage

Coverage 100%

Importance

Changes 9
Bugs 1 Features 2
Metric Value
wmc 5
c 9
b 1
f 2
lcom 1
cbo 2
dl 0
loc 36
rs 10
ccs 10
cts 10
cp 1

4 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 4 1
A getConfig() 0 4 1
A getType() 0 4 1
A resolve() 0 6 2
1
<?php
2
/**
3
 * Date: 27.11.15
4
 *
5
 * @author Portey Vasil <[email protected]>
6
 */
7
8
namespace Youshido\GraphQL\Type\Field;
9
10
11
use Youshido\GraphQL\Type\Config\Field\FieldConfig;
12
use Youshido\GraphQL\Type\Config\Traits\ConfigCallTrait;
13
use Youshido\GraphQL\Type\Object\AbstractObjectType;
14
15
/**
16
 * Class Field
17
 * @package Youshido\GraphQL\Type\Field
18
 *
19
 */
20
class Field
21
{
22
    use ConfigCallTrait;
23
24
    /** @var FieldConfig */
25
    protected $config;
26
27 23
    public function __construct($config)
28
    {
29 23
        $this->config = new FieldConfig($config);
30 23
    }
31
32
    /**
33
     * @return FieldConfig
34
     */
35 19
    public function getConfig()
36
    {
37 19
        return $this->config;
38
    }
39
40
    /**
41
     * @return AbstractObjectType
42
     */
43 21
    public function getType()
44
    {
45 21
        return $this->config->get('type');
46
    }
47
48
49 17
    public function resolve($value, $args, $type)
50
    {
51 17
        $resolveFn = $this->config->get('resolve', null);
52
53 17
        return $resolveFn ? $resolveFn($value, $args, $type) : null;
54
    }
55
}
56