Completed
Pull Request — master (#2)
by Adrien
02:16
created

Argument   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 42
Duplicated Lines 33.33 %

Coupling/Cohesion

Components 1
Dependencies 0

Test Coverage

Coverage 0%

Importance

Changes 0
Metric Value
wmc 2
lcom 1
cbo 0
dl 14
loc 42
ccs 0
cts 12
cp 0
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 field argument in GraphQL.
11
 *
12
 * All values are optional and should only be used to override
13
 * what is declared by the original argument of the method.
14
 *
15
 * @Annotation
16
 * @Target({"ANNOTATION"})
17
 */
18
class Argument
19
{
20
    /**
21
     * The name of the argument, it must matches the actual PHP argument name
22
     *
23
     * @var string
24
     * @Required
25
     */
26
    public $name;
27
28
    /**
29
     * FQCN of PHP class implementing the GraphQL type
30
     *
31
     * @var string
32
     */
33
    public $type;
34
35
    /**
36
     * @var string
37
     */
38
    public $description;
39
40
    /**
41
     * @var mixed
42
     */
43
    public $defaultValue;
44
45 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...
46
    {
47
        $data = [
48
            'name' => $this->name,
49
            'type' => $this->type,
50
            'description' => $this->description,
51
        ];
52
53
        if ($this->defaultValue !== null) {
54
            $data['defaultValue'] = $this->defaultValue;
55
        }
56
57
        return $data;
58
    }
59
}
60