Code Duplication    Length = 48-51 lines in 2 locations

src/Type/Object/AbstractInterfaceType.php 1 location

@@ 16-63 (lines=48) @@
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
    public function __construct($config = [])
25
    {
26
        if (empty($config)) {
27
            $config['name'] = $this->getName();
28
        }
29
30
        $this->config = new InterfaceTypeConfig($config, $this);
31
    }
32
33
    abstract protected function build(InterfaceTypeConfig $config);
34
35
    public function resolveType($object)
36
    {
37
        return $object;
38
    }
39
40
    public function checkBuild()
41
    {
42
        if (!$this->isBuild) {
43
            $this->isBuild = true;
44
            $this->build($this->config);
45
        }
46
    }
47
48
    public function getName()
49
    {
50
        return $this->getConfig()->get('name', 'InterfaceType');
51
    }
52
53
    public function getKind()
54
    {
55
        return TypeMap::KIND_INTERFACE;
56
    }
57
58
    public function isValidValue($value)
59
    {
60
        return true;
61
    }
62
63
}

src/Type/Object/AbstractUnionType.php 1 location

@@ 17-67 (lines=51) @@
14
use Youshido\GraphQL\Type\Config\Object\UnionTypeConfig;
15
use Youshido\GraphQL\Type\TypeMap;
16
17
abstract class AbstractUnionType extends AbstractType
18
{
19
20
21
    /**
22
     * ObjectType constructor.
23
     * @param $config
24
     */
25
    public function __construct($config = [])
26
    {
27
        if (empty($config)) {
28
            $config['name']  = $this->getName();
29
            $config['types'] = $this->getTypes();
30
        }
31
32
        $this->config = new UnionTypeConfig($config, $this);
33
    }
34
35
    public function getName()
36
    {
37
        return $this->getConfig()->get('name', 'UnionType');
38
    }
39
40
    abstract public function resolveType($object);
41
42
    abstract public function getTypes();
43
44
    public function checkBuild()
45
    {
46
        if (!$this->isBuild) {
47
            $this->isBuild = true;
48
            $this->build($this->config);
49
        }
50
    }
51
52
    protected function build(UnionTypeConfig $config)
53
    {
54
55
    }
56
57
    public function getKind()
58
    {
59
        return TypeMap::KIND_UNION;
60
    }
61
62
    public function isValidValue($value)
63
    {
64
        return true;
65
    }
66
67
}