Path   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 9
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
wmc 2
eloc 4
c 0
b 0
f 0
dl 0
loc 9
rs 10

1 Method

Rating   Name   Duplication   Size   Complexity  
A resolveValues() 0 4 2
1
<?php
2
3
namespace Drupal\graphql_core\Plugin\GraphQL\Fields\Routing;
4
5
use Drupal\Core\Url;
0 ignored issues
show
Bug introduced by
The type Drupal\Core\Url 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\GraphQL\Cache\CacheableValue;
7
use Drupal\graphql\GraphQL\Execution\ResolveContext;
8
use Drupal\graphql\Plugin\GraphQL\Fields\FieldPluginBase;
9
use GraphQL\Type\Definition\ResolveInfo;
10
11
/**
12
 * @GraphQLField(
13
 *   id = "url_path",
14
 *   secure = true,
15
 *   name = "path",
16
 *   description = @Translation("The processed url path."),
17
 *   type = "String",
18
 *   response_cache_contexts = {"languages:language_url"},
19
 *   parents = {"Url"}
20
 * )
21
 */
22
class Path extends FieldPluginBase {
23
24
  /**
25
   * {@inheritdoc}
26
   */
27
  public function resolveValues($value, array $args, ResolveContext $context, ResolveInfo $info) {
28
    if ($value instanceof Url) {
29
      $url = $value->toString(TRUE);
30
      yield new CacheableValue($url->getGeneratedUrl(), [$url]);
31
    }
32
  }
33
34
}
35