Completed
Push — master ( 461e07...b4459a )
by Alexandr
03:37
created

AbstractInterfaceType   A

Complexity

Total Complexity 8

Size/Duplication

Total Lines 40
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 5

Test Coverage

Coverage 78.56%

Importance

Changes 7
Bugs 2 Features 1
Metric Value
wmc 8
c 7
b 2
f 1
lcom 0
cbo 5
dl 0
loc 40
rs 10
ccs 11
cts 14
cp 0.7856

5 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 8 2
resolveType() 0 1 ?
A getKind() 0 4 1
A getNamedType() 0 4 1
A isValidValue() 0 9 4
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:12 AM
7
*/
8
9
namespace Youshido\GraphQL\Type\Object;
10
11
12
use Youshido\GraphQL\Type\AbstractType;
13
use Youshido\GraphQL\Type\Config\Object\InterfaceTypeConfig;
14
use Youshido\GraphQL\Type\Config\Traits\ConfigCallTrait;
15
use Youshido\GraphQL\Type\Config\TypeConfigInterface;
16
use Youshido\GraphQL\Type\Traits\AutoNameTrait;
17
use Youshido\GraphQL\Type\TypeMap;
18
19
abstract class AbstractInterfaceType extends AbstractType
20
{
21
    use ConfigCallTrait, AutoNameTrait;
22
23
    /**
24
     * ObjectType constructor.
25
     * @param $config
26
     */
27 8
    public function __construct($config = [])
28
    {
29 8
        if (empty($config)) {
30 8
            $config['name'] = $this->getName();
31
        }
32
33 8
        $this->config = new InterfaceTypeConfig($config, $this);
0 ignored issues
show
Documentation Bug introduced by
It seems like new \Youshido\GraphQL\Ty...eConfig($config, $this) of type object<Youshido\GraphQL\...ct\InterfaceTypeConfig> is incompatible with the declared type object<Youshido\GraphQL\...\InputObjectTypeConfig> of property $config.

Our type inference engine has found an assignment to a property that is incompatible with the declared type of that property.

Either this assignment is in error or the assigned type should be added to the documentation/type hint for that property..

Loading history...
34 8
    }
35
36
    abstract public function resolveType($object);
37
38 8
    public function getKind()
39
    {
40 8
        return TypeMap::KIND_INTERFACE;
41
    }
42
43
    public function getNamedType()
44
    {
45
        return $this;
46
    }
47
48 2
    public function isValidValue($value)
49
    {
50 2
        if ($value instanceof AbstractObjectType) {
51 2
            foreach($value->getInterfaces() as $interface) {
52 2
                if ($interface instanceof $this) return true;
53
            }
54
        }
55
        return false;
56
    }
57
58
}
59