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

EnumType   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 27
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 3

Test Coverage

Coverage 80%

Importance

Changes 1
Bugs 0 Features 1
Metric Value
wmc 4
c 1
b 0
f 1
lcom 0
cbo 3
dl 0
loc 27
ccs 8
cts 10
cp 0.8
rs 10

3 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 8 2
A getValues() 0 4 1
A getName() 0 4 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
use Youshido\GraphQL\Type\Config\Object\EnumTypeConfig;
11
12
final class EnumType extends AbstractEnumType
13
{
14
15
    /**
16
     * ObjectType constructor.
17
     * @param $config
18
     */
19 1
    public function __construct($config = [])
20
    {
21 1
        if (empty($config)) {
22
            $config['name'] = $this->getName();
23
        }
24
25 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...
26 1
    }
27
28 1
    public function getValues()
29
    {
30 1
        return $this->getConfig()->getValues();
0 ignored issues
show
Documentation Bug introduced by
The method getValues does not exist on object<Youshido\GraphQL\...bject\ObjectTypeConfig>? Since you implemented __call, maybe consider adding a @method annotation.

If you implement __call and you know which methods are available, you can improve IDE auto-completion and static analysis by adding a @method annotation to the class.

This is often the case, when __call is implemented by a parent class and only the child class knows which methods exist:

class ParentClass {
    private $data = array();

    public function __call($method, array $args) {
        if (0 === strpos($method, 'get')) {
            return $this->data[strtolower(substr($method, 3))];
        }

        throw new \LogicException(sprintf('Unsupported method: %s', $method));
    }
}

/**
 * If this class knows which fields exist, you can specify the methods here:
 *
 * @method string getName()
 */
class SomeClass extends ParentClass { }
Loading history...
31
    }
32
33 1
    public function getName()
34
    {
35 1
        return $this->getConfig()->getName();
36
    }
37
38
}
39