ConstraintViolationCode   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 8
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
wmc 2
eloc 3
c 0
b 0
f 0
dl 0
loc 8
rs 10

1 Method

Rating   Name   Duplication   Size   Complexity  
A resolveValues() 0 3 2
1
<?php
2
3
namespace Drupal\graphql_core\Plugin\GraphQL\Fields\Mutations;
4
5
use Drupal\graphql\GraphQL\Execution\ResolveContext;
6
use Drupal\graphql\Plugin\GraphQL\Fields\FieldPluginBase;
7
use Symfony\Component\Validator\ConstraintViolationInterface;
0 ignored issues
show
Bug introduced by
The type Symfony\Component\Valida...raintViolationInterface 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...
8
use GraphQL\Type\Definition\ResolveInfo;
9
10
/**
11
 * Retrieve the error code of an entity constraint violation.
12
 *
13
 * @GraphQLField(
14
 *   id = "constraint_violation_code",
15
 *   secure = true,
16
 *   name = "code",
17
 *   type = "String",
18
 *   parents = {"ConstraintViolation"}
19
 * )
20
 */
21
class ConstraintViolationCode extends FieldPluginBase {
22
23
  /**
24
   * {@inheritdoc}
25
   */
26
  public function resolveValues($value, array $args, ResolveContext $context, ResolveInfo $info) {
27
    if ($value instanceof ConstraintViolationInterface) {
28
      yield $value->getCode();
29
    }
30
  }
31
32
}
33