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

AbstractInterfaceType::resolveType()

Size

Total Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 2
Bugs 0 Features 0
Metric Value
c 2
b 0
f 0
dl 0
loc 1
ccs 0
cts 0
cp 0
nc 1
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