EntityCrudOutputWrapper   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 72
Duplicated Lines 0 %

Importance

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

4 Methods

Rating   Name   Duplication   Size   Complexity  
A getEntity() 0 2 1
A getErrors() 0 2 1
A __construct() 0 8 1
A getViolations() 0 2 1
1
<?php
2
3
namespace Drupal\graphql_core\GraphQL;
4
5
use Drupal\Core\Entity\EntityInterface;
0 ignored issues
show
Bug introduced by
The type Drupal\Core\Entity\EntityInterface 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 Symfony\Component\Validator\ConstraintViolationListInterface;
0 ignored issues
show
Bug introduced by
The type Symfony\Component\Valida...tViolationListInterface 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...
7
8
class EntityCrudOutputWrapper {
9
  /**
10
   * The create entity.
11
   *
12
   * @var \Drupal\Core\Entity\EntityInterface|null
13
   */
14
  protected $entity;
15
16
  /**
17
   * The constraint validation list.
18
   *
19
   * @var \Symfony\Component\Validator\ConstraintViolationListInterface|null
20
   */
21
  protected $violations;
22
23
  /**
24
   * An array of error messages.
25
   *
26
   * @var array|null
27
   */
28
  protected $errors;
29
30
  /**
31
   * CreateEntityOutputWrapper constructor.
32
   *
33
   * @param \Drupal\Core\Entity\EntityInterface|null $entity
34
   *   The entity object that has been created or NULL if creation failed.
35
   * @param \Symfony\Component\Validator\ConstraintViolationListInterface|null $violations
36
   *   The validation errors that occurred during creation or NULL if validation
37
   *   succeeded.
38
   * @param array|null $errors
39
   *   An array of non validation error messages. Can be used to provide
40
   *   additional error messages e.g. for access restrictions.
41
   */
42
  public function __construct(
43
    EntityInterface $entity = NULL,
44
    ConstraintViolationListInterface $violations = NULL,
45
    array $errors = NULL
46
  ) {
47
    $this->entity = $entity;
48
    $this->violations = $violations;
49
    $this->errors = $errors;
50
  }
51
52
  /**
53
   * Returns the entity that was created.
54
   *
55
   * @return \Drupal\Core\Entity\EntityInterface|null
56
   *   The created entity object or NULL if creation failed.
57
   */
58
  public function getEntity() {
59
    return $this->entity;
60
  }
61
62
  /**
63
   * Returns the constraint violations.
64
   *
65
   * @return \Symfony\Component\Validator\ConstraintViolationListInterface|null
66
   *   The constraint validations or NULL if validation passed.
67
   */
68
  public function getViolations() {
69
    return $this->violations;
70
  }
71
72
  /**
73
   * Returns a list of error messages that occurred during entity creation.
74
   *
75
   * @return array|null
76
   *   An array of error messages as plain strings.
77
   */
78
  public function getErrors() {
79
    return $this->errors;
80
  }
81
82
}
83