Completed
Push — 8.x-3.x ( e67c0e...2e01b0 )
by Philipp
02:27
created

BatchedField   A

Complexity

Total Complexity 9

Size/Duplication

Total Lines 35
Duplicated Lines 40 %

Coupling/Cohesion

Components 1
Dependencies 1

Importance

Changes 0
Metric Value
dl 14
loc 35
rs 10
c 0
b 0
f 0
wmc 9
lcom 1
cbo 1

3 Methods

Rating   Name   Duplication   Size   Complexity  
A getBatchedFieldResolver() 7 7 3
A getBatchId() 7 7 3
A resolveBatch() 0 7 3

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 Drupal\graphql\GraphQL\Field;
4
5
use Drupal\graphql\GraphQL\Batching\BatchedFieldInterface;
6
use Youshido\GraphQL\Execution\ResolveInfo;
7
8
class BatchedField extends Field implements BatchedFieldInterface {
9
10
  /**
11
   * {@inheritdoc}
12
   */
13 View Code Duplication
  public function getBatchedFieldResolver($parent, array $arguments, ResolveInfo $info) {
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...
14
    if (($plugin = $this->getPluginFromResolveInfo($info)) && $plugin instanceof BatchedFieldInterface) {
15
      return $plugin->getBatchedFieldResolver($parent, $arguments, $info);
16
    }
17
18
    return NULL;
19
  }
20
21
  /**
22
   * {@inheritdoc}
23
   */
24 View Code Duplication
  public function getBatchId($parent, array $arguments, ResolveInfo $info) {
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...
25
    if (($plugin = $this->getPluginFromResolveInfo($info)) && $plugin instanceof BatchedFieldInterface) {
26
      return $plugin->getBatchId($parent, $arguments, $info);
27
    }
28
29
    return NULL;
30
  }
31
32
  /**
33
   * {@inheritdoc}
34
   */
35
  public function resolveBatch(array $batch) {
36
    if (($plugin = $this->getPluginFromResolveInfo($batch['info'])) && $plugin instanceof BatchedFieldInterface) {
37
      return $plugin->resolveBatch($batch);
38
    }
39
40
    return NULL;
41
  }
42
}
43