FieldArgument   A
last analyzed

Complexity

Total Complexity 8

Size/Duplication

Total Lines 74
Duplicated Lines 100 %

Coupling/Cohesion

Components 1
Dependencies 0

Test Coverage

Coverage 94.44%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 8
c 1
b 0
f 0
lcom 1
cbo 0
dl 74
loc 74
ccs 17
cts 18
cp 0.9444
rs 10

5 Methods

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