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

AbstractInterfaceType::isPossibleType()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 1
Bugs 0 Features 1
Metric Value
c 1
b 0
f 1
dl 0
loc 4
ccs 0
cts 2
cp 0
rs 10
nc 1
cc 1
eloc 1
nop 0
crap 2
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\TypeMap;
15
16
abstract class AbstractInterfaceType extends AbstractType
17
{
18
19
20
    /**
21
     * ObjectType constructor.
22
     * @param $config
23
     */
24 6
    public function __construct($config = [])
25
    {
26 6
        if (empty($config)) {
27 6
            $config['name'] = $this->getName();
28 6
        }
29
30 6
        $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...
31 6
    }
32
33
    abstract protected function build(InterfaceTypeConfig $config);
34
35
    public function resolveType($object)
36
    {
37
        return $object;
38
    }
39
40 4
    public function checkBuild()
41
    {
42 4
        if (!$this->isBuild) {
43 4
            $this->isBuild = true;
44 4
            $this->build($this->config);
0 ignored issues
show
Documentation introduced by
$this->config is of type object<Youshido\GraphQL\...\InputObjectTypeConfig>, but the function expects a object<Youshido\GraphQL\...ct\InterfaceTypeConfig>.

It seems like the type of the argument is not accepted by the function/method which you are calling.

In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug.

We suggest to add an explicit type cast like in the following example:

function acceptsInteger($int) { }

$x = '123'; // string "123"

// Instead of
acceptsInteger($x);

// we recommend to use
acceptsInteger((integer) $x);
Loading history...
45 4
        }
46 4
    }
47
48
    public function getName()
49
    {
50
        return $this->getConfig()->get('name', 'InterfaceType');
51
    }
52
53 4
    public function getKind()
54
    {
55 4
        return TypeMap::KIND_INTERFACE;
56
    }
57
58
    public function isValidValue($value)
59
    {
60
        return true;
61
    }
62
63
}