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

overblog / GraphQLBundle / 5429016811

pending completion
5429016811

push

github

web-flow
Merge pull request #1071 from TaProhm/append-deprecated-for-inputs-fields

Allow deprecating input fields and arguments (InputObjectType)

4264 of 4333 relevant lines covered (98.41%)

39.09 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]);
49✔
17
    }
18

19
    public function getType(string $gqlType): ?array
20
    {
21
        return $this->classesMap[$gqlType] ?? null;
48✔
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];
49✔
30
    }
49✔
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) {
52✔
38
            if ($config['class'] === $className) {
50✔
39
                if (empty($filteredTypes) || in_array($config['type'], $filteredTypes)) {
50✔
40
                    return $gqlType;
50✔
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 = [];
49✔
62
        foreach ($this->classesMap as $gqlType => $config) {
49✔
63
            if ($config['type'] !== $type) {
49✔
64
                continue;
49✔
65
            }
66

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

72
        return $classNames;
49✔
73
    }
74

75
    public function toArray(): array
76
    {
77
        return $this->classesMap;
49✔
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