InputObjectField   A
last analyzed

Complexity

Total Complexity 8

Size/Duplication

Total Lines 71
Duplicated Lines 100 %

Coupling/Cohesion

Components 1
Dependencies 0

Test Coverage

Coverage 81.25%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 8
c 1
b 0
f 0
lcom 1
cbo 0
dl 71
loc 71
ccs 13
cts 16
cp 0.8125
rs 10

5 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 7 7 3
A getType() 8 8 2
A getName() 4 4 1
A getDescription() 4 4 1
A getDefaultValue() 4 4 1

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
namespace Fubhy\GraphQL\Type\Definition;
4
5 View Code Duplication
class InputObjectField
6
{
7
    /**
8
     * @var string
9
     */
10
    protected $name;
11
12
    /**
13
     * @var \Fubhy\GraphQL\Type\Definition\Types\InputTypeInterface|callable
14
     */
15
    protected $type;
16
17
    /**
18
     * @var mixed|null
19
     */
20
    protected $defaultValue;
21
22
    /**
23
     * @var string|null
24
     */
25
    protected $description;
26
27
    /**
28
     * Constructor.
29
     *
30
     * @param array $config
31
     */
32 9
    public function __construct(array $config)
33
    {
34 9
        $this->name = $config['name'];
35 9
        $this->type = $config['type'];
36 9
        $this->description = isset($config['description']) ? $config['description'] : NULL;
37 9
        $this->defaultValue = isset($config['defaultValue']) ? $config['defaultValue'] : NULL;
38 9
    }
39
40
    /**
41
     * @return \Fubhy\GraphQL\Type\Definition\Types\InputTypeInterface
42
     */
43 9
    public function getType()
44
    {
45 9
        if (is_callable($this->type)) {
46
            return call_user_func($this->type);
47
        }
48
49 9
        return $this->type;
50
    }
51
52
    /**
53
     * @return string
54
     */
55 3
    public function getName()
56
    {
57 3
        return $this->name;
58
    }
59
60
    /**
61
     * @return string|null
62
     */
63
    public function getDescription()
64
    {
65
        return $this->description;
66
    }
67
68
    /**
69
     * @return mixed|null
70
     */
71 3
    public function getDefaultValue()
72
    {
73 3
        return $this->defaultValue;
74
    }
75
}
76