SubscriptionPluginBase   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 33
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 2
eloc 19
c 1
b 0
f 0
dl 0
loc 33
rs 10

2 Methods

Rating   Name   Duplication   Size   Complexity  
A getDefinition() 0 8 1
A createInstance() 0 9 1
1
<?php
2
3
namespace Drupal\graphql\Plugin\GraphQL\Subscriptions;
4
5
use Drupal\Component\Plugin\PluginBase;
0 ignored issues
show
Bug introduced by
The type Drupal\Component\Plugin\PluginBase was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
6
use Drupal\graphql\Plugin\SubscriptionPluginInterface;
7
use Drupal\graphql\Plugin\SubscriptionPluginManager;
8
use Drupal\graphql\Plugin\GraphQL\Traits\ArgumentAwarePluginTrait;
9
use Drupal\graphql\Plugin\GraphQL\Traits\DeprecatablePluginTrait;
10
use Drupal\graphql\Plugin\GraphQL\Traits\DescribablePluginTrait;
11
use Drupal\graphql\Plugin\GraphQL\Traits\TypedPluginTrait;
12
use Drupal\graphql\Plugin\SchemaBuilderInterface;
13
14
abstract class SubscriptionPluginBase extends PluginBase implements SubscriptionPluginInterface {
15
  use TypedPluginTrait;
16
  use DescribablePluginTrait;
17
  use ArgumentAwarePluginTrait;
18
  use DeprecatablePluginTrait;
19
20
  /**
21
   * {@inheritdoc}
22
   */
23
  public static function createInstance(SchemaBuilderInterface $builder, SubscriptionPluginManager $manager, $definition, $id) {
24
    return [
25
      'description' => $definition['description'],
26
      'deprecationReason' => $definition['deprecationReason'],
27
      'type' => $builder->processType($definition['type']),
28
      'args' => $builder->processArguments($definition['args']),
29
      'resolve' => function ($value, $args, $context, $info) use ($manager, $id) {
30
        $instance = $manager->getInstance(['id' => $id]);
31
        return call_user_func_array([$instance, 'resolve'], [$value, $args, $context, $info]);
32
      },
33
    ];
34
  }
35
36
  /**
37
   * {@inheritdoc}
38
   */
39
  public function getDefinition() {
40
    $definition = $this->getPluginDefinition();
41
42
    return [
43
      'type' => $this->buildType($definition),
44
      'description' => $this->buildDescription($definition),
45
      'args' => $this->buildArguments($definition),
46
      'deprecationReason' => $this->buildDeprecationReason($definition),
0 ignored issues
show
Bug introduced by
Are you sure the usage of $this->buildDeprecationReason($definition) targeting Drupal\graphql\Plugin\Gr...uildDeprecationReason() seems to always return null.

This check looks for function or method calls that always return null and whose return value is used.

class A
{
    function getObject()
    {
        return null;
    }

}

$a = new A();
if ($a->getObject()) {

The method getObject() can return nothing but null, so it makes no sense to use the return value.

The reason is most likely that a function or method is imcomplete or has been reduced for debug purposes.

Loading history...
47
    ];
48
  }
49
}
50