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

Field::setType()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 3
CRAP Score 1

Importance

Changes 1
Bugs 1 Features 1
Metric Value
c 1
b 1
f 1
dl 0
loc 4
ccs 3
cts 3
cp 1
rs 10
cc 1
eloc 2
nc 1
nop 1
crap 1
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