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

AbstractEnumType   A

Complexity

Total Complexity 5

Size/Duplication

Total Lines 41
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 2

Test Coverage

Coverage 84.62%

Importance

Changes 1
Bugs 0 Features 1
Metric Value
wmc 5
c 1
b 0
f 1
lcom 0
cbo 2
dl 0
loc 41
ccs 11
cts 13
cp 0.8462
rs 10

5 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 9 2
A getKind() 0 4 1
A isValidValue() 0 4 1
getValues() 0 1 ?
A checkBuild() 0 3 1
1
<?php
2
/**
3
 * Date: 07.12.15
4
 *
5
 * @author Portey Vasil <[email protected]>
6
 */
7
8
namespace Youshido\GraphQL\Type\Object;
9
10
11
use Youshido\GraphQL\Type\AbstractType;
12
use Youshido\GraphQL\Type\Config\Object\EnumTypeConfig;
13
use Youshido\GraphQL\Type\TypeMap;
14
15
abstract class AbstractEnumType extends AbstractType
16
{
17
18
    /**
19
     * ObjectType constructor.
20
     * @param $config
21
     */
22 1
    public function __construct($config = [])
23
    {
24 1
        if (empty($config)) {
25 1
            $config['name'] = $this->getName();
26 1
            $config['values'] = $this->getValues();
27 1
        }
28
29 1
        $this->config = new EnumTypeConfig($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\EnumTypeConfig> 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...
30 1
    }
31
32
    /**
33
     * @return String predefined type kind
34
     */
35 2
    public function getKind()
36
    {
37 2
        return TypeMap::KIND_ENUM;
38
    }
39
40
    /**
41
     * @param $value mixed
42
     *
43
     * @return bool
44
     */
45
    public function isValidValue($value)
46
    {
47
        return array_key_exists($value, $this->getValues());
48
    }
49
50
    abstract public function getValues();
51
52 2
    public function checkBuild()
53
    {
54 2
    }
55
}
56