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

Passed
Pull Request — master (#801)
by Timur
20:26
created

AnnotationParser::getGraphQLFieldsFromProviders()   F

Complexity

Conditions 23
Paths 1001

Size

Total Lines 78
Code Lines 45

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 43
CRAP Score 23.0061

Importance

Changes 3
Bugs 1 Features 0
Metric Value
eloc 45
dl 0
loc 78
ccs 43
cts 44
cp 0.9773
c 3
b 1
f 0
rs 0
cc 23
nc 1001
nop 4
crap 23.0061

How to fix   Long Method    Complexity   

Long Method

Small methods make your code easier to understand, in particular if combined with a good name. Besides, if your method is small, finding a good name is usually much easier.

For example, if you find yourself adding comments to a method's body, this is usually a good sign to extract the commented part to a new method, and use the comment as a starting point when coming up with a good name for this new method.

Commonly applied refactorings include:

1
<?php
2
3
declare(strict_types=1);
4
5
namespace Overblog\GraphQLBundle\Config\Parser;
6
7
use Doctrine\Common\Annotations\AnnotationReader;
8
use Doctrine\Common\Annotations\AnnotationRegistry;
9
use Overblog\GraphQLBundle\Config\Parser\MetadataParser\MetadataParser;
10
use ReflectionClass;
11
use ReflectionMethod;
12
use ReflectionProperty;
13
use Reflector;
14
use RuntimeException;
15
16
class AnnotationParser extends MetadataParser
17
{
18
    const METADATA_FORMAT = '@%s';
19
20
    protected static ?AnnotationReader $annotationReader = null;
21
22
    protected static function getMetadatas(Reflector $reflector): array
23
    {
24
        $reader = self::getAnnotationReader();
25
26
        switch (true) {
27
            case $reflector instanceof ReflectionClass: return $reader->getClassAnnotations($reflector);
28
            case $reflector instanceof ReflectionMethod: return $reader->getMethodAnnotations($reflector);
29
            case $reflector instanceof ReflectionProperty: return $reader->getPropertyAnnotations($reflector);
30
        }
31
32
        return [];
33
    }
34
35
    protected static function getAnnotationReader(): AnnotationReader
36
    {
37
        if (null === self::$annotationReader) {
38
            if (!class_exists(AnnotationReader::class) ||
39
                !class_exists(AnnotationRegistry::class)) {
40
                throw new RuntimeException('In order to use graphql annotation, you need to require doctrine annotations');
41
            }
42
43
            AnnotationRegistry::registerLoader('class_exists');
0 ignored issues
show
Deprecated Code introduced by
The function Doctrine\Common\Annotati...istry::registerLoader() has been deprecated: This method is deprecated and will be removed in doctrine/annotations 2.0. Annotations will be autoloaded in 2.0. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-deprecated  annotation

43
            /** @scrutinizer ignore-deprecated */ AnnotationRegistry::registerLoader('class_exists');

This function has been deprecated. The supplier of the function has supplied an explanatory message.

The explanatory message should give you some clue as to whether and when the function will be removed and what other function to use instead.

Loading history...
44
            self::$annotationReader = new AnnotationReader();
45
        }
46
47
        return self::$annotationReader;
48
    }
49
}
50