Completed
Push — master ( d01340...7e7fa7 )
by Portey
07:36
created

InterfaceTypeConfig   A

Complexity

Total Complexity 5

Size/Duplication

Total Lines 30
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 3

Test Coverage

Coverage 92.86%

Importance

Changes 4
Bugs 0 Features 0
Metric Value
wmc 5
c 4
b 0
f 0
lcom 1
cbo 3
dl 0
loc 30
ccs 13
cts 14
cp 0.9286
rs 10

3 Methods

Rating   Name   Duplication   Size   Complexity  
A getRules() 0 9 1
A build() 0 4 1
A resolveType() 0 10 3
1
<?php
2
/*
3
* This file is a part of GraphQL project.
4
*
5
* @author Alexandr Viniychuk <[email protected]>
6
* created: 12/5/15 12:18 AM
7
*/
8
9
namespace Youshido\GraphQL\Type\Config\Object;
10
11
12
use Youshido\GraphQL\Type\Config\Config;
13
use Youshido\GraphQL\Type\Config\Traits\ArgumentsAwareTrait;
14
use Youshido\GraphQL\Type\Config\Traits\FieldsAwareTrait;
15
use Youshido\GraphQL\Type\Config\TypeConfigInterface;
16
use Youshido\GraphQL\Type\TypeMap;
17
18
class InterfaceTypeConfig extends Config implements TypeConfigInterface
19
{
20
    use FieldsAwareTrait, ArgumentsAwareTrait;
21
22 6
    public function getRules()
23
    {
24
        return [
25 6
            'name'        => ['type' => TypeMap::TYPE_STRING, 'required' => true],
26 6
            'fields'      => ['type' => TypeMap::TYPE_ARRAY_OF_FIELDS],
27 6
            'description' => ['type' => TypeMap::TYPE_STRING],
28 6
            'resolveType' => ['type' => TypeMap::TYPE_FUNCTION]
29 6
        ];
30
    }
31
32 6
    protected function build()
33
    {
34 6
        $this->buildFields();
35 6
    }
36
37 2
    public function resolveType($object)
38
    {
39 2
        $callable = $this->get('resolveType');
40
41 2
        if($callable && is_callable($callable)) {
42
            return call_user_func_array($callable, [$object]);
43
        }
44
45 2
        return $this->contextObject->resolveType($object);
46
    }
47
}