Code Duplication    Length = 22-23 lines in 2 locations

src/Type/AbstractObjectType.php 1 location

@@ 86-108 (lines=23) @@
83
            }
84
85
            $args = [];
86
            foreach ($fieldDefinition->getArguments() as $argument) {
87
                $argumentType = Types::get($argument->getType());
88
89
                if ($argument->isList()) {
90
                    if ($argument->isNonNullList()) {
91
                        $argumentType = Type::nonNull($type);
92
                    }
93
                    $argumentType = Type::listOf($argumentType);
94
                }
95
96
                if ($argument->isNonNull()) {
97
                    $argumentType = Type::nonNull($argumentType);
98
                }
99
                $arg['name'] = $argument->getName();
100
                $arg['type'] = $argumentType;
101
                $arg['description'] = $argument->getDescription();
102
103
                if ($argument->getDefaultValue() !== null) {
104
                    $arg['defaultValue'] = $argument->getDefaultValue();
105
                }
106
107
                $args[] = $arg;
108
            }
109
110
            $fields[$fieldDefinition->getName()] = [
111
                'type' => $type,

src/Type/QueryType.php 1 location

@@ 80-101 (lines=22) @@
77
    protected function resolveArguments(QueryDefinition $query): array
78
    {
79
        $args = [];
80
        foreach ($query->getArguments() as $argDefinition) {
81
            $arg = [];
82
            $arg['description'] = $argDefinition->getDescription();
83
            $type = Types::get($argDefinition->getType());
84
85
            if ($argDefinition->isList()) {
86
                if ($argDefinition->isNonNullList()) {
87
                    $type = Type::nonNull($type);
88
                }
89
                $type = Type::listOf($type);
90
            }
91
92
            if ($argDefinition->isNonNull()) {
93
                $type = Type::nonNull($type);
94
            }
95
96
            $arg['type'] = $type;
97
            if ($argDefinition->getDefaultValue()) {
98
                $arg['defaultValue'] = $argDefinition->getDefaultValue();
99
            }
100
            $args[$argDefinition->getName()] = $arg;
101
        }
102
103
        return $args;
104
    }