Completed
Push — master ( 3aac06...366db0 )
by Adrien
01:53
created

Input   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 39
Duplicated Lines 35.9 %

Coupling/Cohesion

Components 1
Dependencies 0

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
wmc 2
lcom 1
cbo 0
dl 14
loc 39
ccs 7
cts 7
cp 1
rs 10
c 0
b 0
f 0

1 Method

Rating   Name   Duplication   Size   Complexity  
A toArray() 14 14 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
declare(strict_types=1);
4
5
namespace GraphQL\Doctrine\Annotation;
6
7
use GraphQL\Type\Definition\Type;
8
9
/**
10
 * Annotation used to override values for an input field in GraphQL.
11
 *
12
 * All values are optional and should only be used to override
13
 * what is declared by the original method.
14
 *
15
 * @Annotation
16
 * @Target({"METHOD"})
17
 */
18
class Input
19
{
20
    /**
21
     * @var string
22
     */
23
    public $name;
24
25
    /**
26
     * FQCN of PHP class implementing the GraphQL type
27
     *
28
     * @var string
29
     */
30
    public $type;
31
32
    /**
33
     * @var string
34
     */
35
    public $description;
36
37
    /**
38
     * @var mixed
39
     */
40
    public $defaultValue;
41
42 1 View Code Duplication
    public function toArray(): array
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...
43
    {
44
        $data = [
45 1
            'name' => $this->name,
46 1
            'type' => $this->type,
47 1
            'description' => $this->description,
48
        ];
49
50 1
        if ($this->defaultValue !== null) {
51 1
            $data['defaultValue'] = $this->defaultValue;
52
        }
53
54 1
        return $data;
55
    }
56
}
57