ImageWidth   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 8
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 4
eloc 3
c 1
b 0
f 0
dl 0
loc 8
rs 10

1 Method

Rating   Name   Duplication   Size   Complexity  
A resolveValues() 0 3 4
1
<?php
2
3
namespace Drupal\graphql_core\Plugin\GraphQL\Fields\Entity\Fields\Image;
4
5
use Drupal\graphql\GraphQL\Execution\ResolveContext;
6
use Drupal\graphql\Plugin\GraphQL\Fields\FieldPluginBase;
7
use Drupal\image\Plugin\Field\FieldType\ImageItem;
0 ignored issues
show
Bug introduced by
The type Drupal\image\Plugin\Field\FieldType\ImageItem 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 image width.
12
 *
13
 * @GraphQLField(
14
 *   id = "image_width",
15
 *   secure = true,
16
 *   name = "width",
17
 *   type = "Int",
18
 *   provider = "image",
19
 *   field_types = {"image"},
20
 *   deriver = "Drupal\graphql_core\Plugin\Deriver\Fields\EntityFieldPropertyDeriver"
21
 * )
22
 */
23
class ImageWidth extends FieldPluginBase {
24
25
  /**
26
   * {@inheritdoc}
27
   */
28
  protected function resolveValues($value, array $args, ResolveContext $context, ResolveInfo $info) {
29
    if ($value instanceof ImageItem && $value->entity && $value->entity->access('view')) {
30
      yield (int) $value->width;
31
    }
32
  }
33
34
}
35