Completed
Pull Request — 8.x-3.x (#503)
by Sebastian
02:58 queued 50s
created

UploadType   A

Complexity

Total Complexity 5

Size/Duplication

Total Lines 38
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 1

Importance

Changes 0
Metric Value
wmc 5
lcom 0
cbo 1
dl 0
loc 38
rs 10
c 0
b 0
f 0

5 Methods

Rating   Name   Duplication   Size   Complexity  
A getName() 0 3 1
A serialize() 0 3 1
A parseValue() 0 3 1
A parseInputValue() 0 3 1
A isValidValue() 0 3 1
1
<?php
2
3
namespace Drupal\graphql\GraphQL\Type;
4
5
use Symfony\Component\HttpFoundation\File\UploadedFile;
6
use Youshido\GraphQL\Type\Scalar\AbstractScalarType;
7
8
class UploadType extends AbstractScalarType {
9
10
  /**
11
   * {@inheritdoc}
12
   */
13
  public function getName() {
14
    return 'Upload';
15
  }
16
17
  /**
18
   * {@inheritdoc}
19
   */
20
  public function serialize($value) {
21
    throw new \LogicException('Cannot serialize uploaded files.');
22
  }
23
24
  /**
25
   * {@inheritdoc}
26
   */
27
  public function parseValue($value) {
28
    return $value;
29
  }
30
31
  /**
32
   * {@inheritdoc}
33
   */
34
  public function parseInputValue($value) {
35
    return $value;
36
  }
37
38
  /**
39
   * {@inheritdoc}
40
   */
41
  public function isValidValue($value) {
42
    return $value instanceof UploadedFile;
0 ignored issues
show
Bug introduced by
The class Symfony\Component\HttpFoundation\File\UploadedFile does not exist. Did you forget a USE statement, or did you not list all dependencies?

This error could be the result of:

1. Missing dependencies

PHP Analyzer uses your composer.json file (if available) to determine the dependencies of your project and to determine all the available classes and functions. It expects the composer.json to be in the root folder of your repository.

Are you sure this class is defined by one of your dependencies, or did you maybe not list a dependency in either the require or require-dev section?

2. Missing use statement

PHP does not complain about undefined classes in ìnstanceof checks. For example, the following PHP code will work perfectly fine:

if ($x instanceof DoesNotExist) {
    // Do something.
}

If you have not tested against this specific condition, such errors might go unnoticed.

Loading history...
43
  }
44
45
}
46