AbstractUnionType   A
last analyzed

Complexity

Total Complexity 5

Size/Duplication

Total Lines 42
Duplicated Lines 21.43 %

Coupling/Cohesion

Components 0
Dependencies 4

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
wmc 5
lcom 0
cbo 4
dl 9
loc 42
ccs 13
cts 13
cp 1
rs 10
c 0
b 0
f 0

5 Methods

Rating   Name   Duplication   Size   Complexity  
getTypes() 0 1 ?
A getKind() 0 4 1
A getNamedType() 0 4 1
A isValidValue() 0 4 1
A __construct() 9 9 2

How to fix   Duplicated Code   

Duplicated Code

Duplicate code is one of the most pungent code smells. A rule that is often used is to re-structure code once it is duplicated in three or more places.

Common duplication problems, and corresponding solutions are:

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\Union;
10
11
12
use Youshido\GraphQL\Config\Object\UnionTypeConfig;
13
use Youshido\GraphQL\Config\Traits\ConfigAwareTrait;
14
use Youshido\GraphQL\Type\AbstractInterfaceTypeInterface;
15
use Youshido\GraphQL\Type\AbstractType;
16
use Youshido\GraphQL\Type\Object\AbstractObjectType;
17
use Youshido\GraphQL\Type\Scalar\AbstractScalarType;
18
use Youshido\GraphQL\Type\Traits\AutoNameTrait;
19
use Youshido\GraphQL\Type\TypeMap;
20
21
abstract class AbstractUnionType extends AbstractType implements AbstractInterfaceTypeInterface
22
{
23
24
    use ConfigAwareTrait, AutoNameTrait;
25
26
    protected $isFinal = false;
27
28
    /**
29
     * ObjectType constructor.
30
     * @param $config
31
     */
32 7 View Code Duplication
    public function __construct($config = [])
0 ignored issues
show
Duplication introduced by
This method 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...
33
    {
34 7
        if (empty($config)) {
35 1
            $config['name']  = $this->getName();
36 1
            $config['types'] = $this->getTypes();
37 1
        }
38
39 7
        $this->config = new UnionTypeConfig($config, $this, $this->isFinal);
40 7
    }
41
42
    /**
43
     * @return AbstractObjectType[]|AbstractScalarType[]
44
     */
45
    abstract public function getTypes();
46
47 4
    public function getKind()
48
    {
49 4
        return TypeMap::KIND_UNION;
50
    }
51
52 2
    public function getNamedType()
53
    {
54 2
        return $this;
55
    }
56
57 3
    public function isValidValue($value)
58
    {
59 3
        return true;
60
    }
61
62
}
63