• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

overblog / GraphQLBundle / 7925843142

01 Feb 2024 03:10PM UTC coverage: 98.431%. Remained the same
7925843142

push

github

web-flow
Merge pull request #1157 from cfv1000/master

fix issue with parsing invalid files

4267 of 4335 relevant lines covered (98.43%)

39.33 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

94.44
/src/Config/Parser/MetadataParser/ClassesTypesMap.php
1
<?php
2

3
declare(strict_types=1);
4

5
namespace Overblog\GraphQLBundle\Config\Parser\MetadataParser;
6

7
final class ClassesTypesMap
8
{
9
    /**
10
     * @var array<string, array{class: string, type: string}>
11
     */
12
    private array $classesMap = [];
13

14
    public function hasType(string $gqlType): bool
15
    {
16
        return isset($this->classesMap[$gqlType]);
51✔
17
    }
18

19
    public function getType(string $gqlType): ?array
20
    {
21
        return $this->classesMap[$gqlType] ?? null;
50✔
22
    }
23

24
    /**
25
     * Add a class & a type to the map
26
     */
27
    public function addClassType(string $typeName, string $className, string $graphQLType): void
28
    {
29
        $this->classesMap[$typeName] = ['class' => $className, 'type' => $graphQLType];
51✔
30
    }
51✔
31

32
    /**
33
     * Resolve the type associated with given class name
34
     */
35
    public function resolveType(string $className, array $filteredTypes = []): ?string
36
    {
37
        foreach ($this->classesMap as $gqlType => $config) {
54✔
38
            if ($config['class'] === $className) {
52✔
39
                if (empty($filteredTypes) || in_array($config['type'], $filteredTypes)) {
52✔
40
                    return $gqlType;
52✔
41
                }
42
            }
43
        }
44

45
        return null;
4✔
46
    }
47

48
    /**
49
     * Resolve the class name associated with given type
50
     */
51
    public function resolveClass(string $typeName): ?string
52
    {
53
        return $this->classesMap[$typeName]['class'] ?? null;
×
54
    }
55

56
    /**
57
     * Search the classes map for class by predicate.
58
     */
59
    public function searchClassesMapBy(callable $predicate, string $type): array
60
    {
61
        $classNames = [];
51✔
62
        foreach ($this->classesMap as $gqlType => $config) {
51✔
63
            if ($config['type'] !== $type) {
51✔
64
                continue;
51✔
65
            }
66

67
            if ($predicate($gqlType, $config)) {
50✔
68
                $classNames[$gqlType] = $config;
50✔
69
            }
70
        }
71

72
        return $classNames;
51✔
73
    }
74

75
    public function toArray(): array
76
    {
77
        return $this->classesMap;
51✔
78
    }
79
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2025 Coveralls, Inc