FieldConfig   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 33
Duplicated Lines 39.39 %

Coupling/Cohesion

Components 1
Dependencies 2

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
wmc 3
lcom 1
cbo 2
dl 13
loc 33
ccs 15
cts 15
cp 1
rs 10
c 0
b 0
f 0

3 Methods

Rating   Name   Duplication   Size   Complexity  
A build() 0 4 1
A getType() 0 4 1
A getRules() 13 13 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
* This file is a part of graphql-youshido project.
4
*
5
* @author Alexandr Viniychuk <[email protected]>
6
* created: 11/30/15 1:30 AM
7
*/
8
9
namespace Youshido\GraphQL\Config\Field;
10
11
use Youshido\GraphQL\Config\AbstractConfig;
12
use Youshido\GraphQL\Config\Traits\ArgumentsAwareConfigTrait;
13
use Youshido\GraphQL\Type\Object\AbstractObjectType;
14
use Youshido\GraphQL\Type\TypeInterface;
15
use Youshido\GraphQL\Type\TypeService;
16
17
/**
18
 * Class FieldConfig
19
 * @package Youshido\GraphQL\Config\Field
20
 * @method $this setDescription(string $description)
21
 * @method $this setCost(int $cost)
22
 */
23
class FieldConfig extends AbstractConfig
24
{
25
26
    use ArgumentsAwareConfigTrait;
27
28 80 View Code Duplication
    public function getRules()
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...
29
    {
30
        return [
31 80
            'name'              => ['type' => TypeService::TYPE_STRING, 'final' => true],
32 80
            'type'              => ['type' => TypeService::TYPE_GRAPHQL_TYPE, 'final' => true],
33 80
            'args'              => ['type' => TypeService::TYPE_ARRAY],
34 80
            'description'       => ['type' => TypeService::TYPE_STRING],
35 80
            'resolve'           => ['type' => TypeService::TYPE_CALLABLE],
36 80
            'isDeprecated'      => ['type' => TypeService::TYPE_BOOLEAN],
37 80
            'deprecationReason' => ['type' => TypeService::TYPE_STRING],
38 80
            'cost'              => ['type' => TypeService::TYPE_ANY]
39 80
        ];
40
    }
41
42 105
    protected function build()
43
    {
44 105
        $this->buildArguments();
45 105
    }
46
47
    /**
48
     * @return TypeInterface|AbstractObjectType
49
     */
50 1
    public function getType()
51
    {
52 1
        return $this->data['type'];
53
    }
54
55
}
56