Completed
Push — master ( f9f0ef...24a695 )
by Portey
05:15
created

AbstractUnionType::resolve()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 3
Ratio 100 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 1
Bugs 1 Features 0
Metric Value
c 1
b 1
f 0
dl 3
loc 3
ccs 0
cts 2
cp 0
rs 10
cc 1
eloc 1
nc 1
nop 2
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\UnionTypeConfig;
14
use Youshido\GraphQL\Type\Config\TypeConfigInterface;
15
use Youshido\GraphQL\Type\TypeMap;
16
17 View Code Duplication
abstract class AbstractUnionType extends AbstractType
0 ignored issues
show
Duplication introduced by
This class seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
18
{
19
20
21
    /**
22
     * ObjectType constructor.
23
     * @param $config
24
     */
25 4
    public function __construct($config = [])
26
    {
27 4
        if (empty($config)) {
28 4
            $config['name']  = $this->getName();
29 4
            $config['types'] = $this->getTypes();
30 4
        }
31
32 4
        $this->config = new UnionTypeConfig($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\...Object\UnionTypeConfig> 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...
33 4
    }
34
35
    abstract public function getName();
36
37
    abstract public function resolveType($object);
38
39
    abstract public function getTypes();
40
41 4
    public function checkBuild()
42
    {
43 4
        if (!$this->isBuild) {
44 4
            $this->isBuild = true;
45 4
            $this->build($this->config);
46 4
        }
47 4
    }
48
49 4
    protected function build(TypeConfigInterface $config)
0 ignored issues
show
Unused Code introduced by
The parameter $config is not used and could be removed.

This check looks from parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
50
    {
51
52 4
    }
53
54
    public function resolve($value = null, $args = []) {
0 ignored issues
show
Unused Code introduced by
The parameter $value is not used and could be removed.

This check looks from parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
Unused Code introduced by
The parameter $args is not used and could be removed.

This check looks from parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
55
56
    }
57
58 4
    public function getKind()
59
    {
60 4
        return TypeMap::KIND_UNION;
61
    }
62
63
    public function isValidValue($value)
64
    {
65
        return true;
66
    }
67
68
}