Completed
Push — master ( 7f89eb...d01340 )
by Portey
05:11
created

AbstractInterfaceType   A

Complexity

Total Complexity 10

Size/Duplication

Total Lines 58
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 3

Test Coverage

Coverage 58.33%

Importance

Changes 1
Bugs 0 Features 1
Metric Value
wmc 10
c 1
b 0
f 1
lcom 1
cbo 3
dl 0
loc 58
ccs 14
cts 24
cp 0.5833
rs 10

9 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 8 2
A getPossibleTypes() 0 4 1
build() 0 1 ?
A checkBuild() 0 7 2
A isPossibleType() 0 4 1
A getObjectType() 0 4 1
A getName() 0 4 1
A getKind() 0 4 1
A isValidValue() 0 4 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\TypeMap;
15
16
abstract class AbstractInterfaceType extends AbstractType
17
{
18
19
20
    /**
21
     * ObjectType constructor.
22
     * @param $config
23
     */
24 1
    public function __construct($config = [])
25
    {
26 1
        if (empty($config)) {
27 1
            $config['name'] = $this->getName();
28 1
        }
29
30 1
        $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 1
    }
32
33
    public function getPossibleTypes()
34
    {
35
36
    }
37
38
    abstract  protected function build(InterfaceTypeConfig $config);
39
40 1
    public function checkBuild()
41
    {
42 1
        if (!$this->isBuild) {
43 1
            $this->isBuild = true;
44 1
            $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 1
        }
46 1
    }
47
48
    public function isPossibleType()
49
    {
50
51
    }
52
53
    public function getObjectType()
54
    {
55
56
    }
57
58
    public function getName()
59
    {
60
        return $this->getConfig()->get('name', 'InterfaceType');
61
    }
62
63 1
    public function getKind()
64
    {
65 1
        return TypeMap::KIND_INTERFACE;
66
    }
67
68
    public function isValidValue($value)
69
    {
70
        return true;
71
    }
72
73
}