Scrutinizer GitHub App not installed

We could not synchronize checks via GitHub's checks API since Scrutinizer's GitHub App is not installed for this repository.

Install GitHub App

Completed
Pull Request — master (#288)
by Jérémiah
15:48
created

GraphQLUploadType   A

Complexity

Total Complexity 6

Size/Duplication

Total Lines 48
Duplicated Lines 25 %

Coupling/Cohesion

Components 1
Dependencies 2

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
wmc 6
lcom 1
cbo 2
dl 12
loc 48
ccs 18
cts 18
cp 1
rs 10
c 0
b 0
f 0

4 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 10 1
A parseValue() 12 12 3
A serialize() 0 4 1
A parseLiteral() 0 4 1

How to fix   Duplicated Code   

Duplicated Code

Duplicate code is one of the most pungent code smells. A rule that is often used is to re-structure code once it is duplicated in three or more places.

Common duplication problems, and corresponding solutions are:

1
<?php
2
3
namespace Overblog\GraphQLBundle\Upload\Type;
4
5
use GraphQL\Error\InvariantViolation;
6
use GraphQL\Type\Definition\ScalarType;
7
use Symfony\Component\HttpFoundation\File\File;
8
9
class GraphQLUploadType extends ScalarType
10
{
11
    /**
12
     * @param string $name
13
     */
14 12
    public function __construct($name = null)
15
    {
16 12
        parent::__construct([
17 12
            'name' => $name,
18 12
            'description' => sprintf(
19 12
                'The `%s` scalar type represents a file upload object that resolves an object containing `stream`, `filename`, `mimetype` and `encoding`.',
20 12
                $name
21
            ),
22
        ]);
23 12
    }
24
25
    /**
26
     * {@inheritdoc}
27
     */
28 10 View Code Duplication
    public function parseValue($value)
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
29
    {
30 10
        if (!$value instanceof File) {
31 6
            throw new InvariantViolation(sprintf(
32 6
                'Upload should be instance of "%s" but %s given.',
33 6
                File::class,
34 6
                is_object($value) ? get_class($value) : gettype($value)
35
            ));
36
        }
37
38 4
        return $value;
39
    }
40
41
    /**
42
     * {@inheritdoc}
43
     */
44 1
    public function serialize($value)
45
    {
46 1
        throw new InvariantViolation(sprintf('%s scalar serialization unsupported.', $this->name));
47
    }
48
49
    /**
50
     * {@inheritdoc}
51
     */
52 1
    public function parseLiteral($valueNode)
53
    {
54 1
        throw new InvariantViolation(sprintf('%s scalar literal unsupported.', $this->name));
55
    }
56
}
57