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

ClassesTypesMap::resolveClass()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 1
c 1
b 0
f 0
nc 1
nop 1
dl 0
loc 3
rs 10
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Overblog\GraphQLBundle\Config\Parser\MetadataParser;
6
7
class ClassesTypesMap
8
{
9
    protected array $classesMap = [];
10
11
    public function hasType(string $gqlType): bool
12
    {
13
        return isset($this->classesMap[$gqlType]);
14
    }
15
16
    public function getType(string $gqlType): ?array
17
    {
18
        return $this->classesMap[$gqlType] ?? null;
19
    }
20
21
    /**
22
     * Add a class & a type to the map
23
     */
24
    public function addClassType(string $typeName, string $className, string $graphQLType): void
25
    {
26
        $this->classesMap[$typeName] = ['class' => $className, 'type' => $graphQLType];
27
    }
28
29
    /**
30
     * Resolve the type associated with given class name
31
     */
32
    public function resolveType(string $className, array $filteredTypes = []): ?string
33
    {
34
        foreach ($this->classesMap as $gqlType => $config) {
35
            if ($config['class'] === $className) {
36
                if (empty($filteredTypes) || in_array($config['type'], $filteredTypes)) {
37
                    return $gqlType;
38
                }
39
            }
40
        }
41
42
        return null;
43
    }
44
45
    /**
46
     * Resolve the class name associated with given type
47
     */
48
    public function resolveClass(string $typeName): ?string
49
    {
50
        return $this->classesMap[$typeName]['class'] ?? null;
51
    }
52
53
    /**
54
     * Search the classes map for class by predicate.
55
     */
56
    public function searchClassesMapBy(callable $predicate, string $type): array
57
    {
58
        $classNames = [];
59
        foreach ($this->classesMap as $gqlType => $config) {
60
            if ($config['type'] !== $type) {
61
                continue;
62
            }
63
64
            if ($predicate($gqlType, $config)) {
65
                $classNames[$gqlType] = $config;
66
            }
67
        }
68
69
        return $classNames;
70
    }
71
72
    public function toArray(): array
73
    {
74
        return $this->classesMap;
75
    }
76
}
77