Code Duplication    Length = 5-5 lines in 4 locations

src/Compiler/Builder/Common/ValueBuilder.php 4 locations

@@ 165-169 (lines=5) @@
162
        /**
163
         * @validation <name: InputType = Value>
164
         */
165
        if (! ($value instanceof InputValueNode)) {
166
            $error = 'Value of %s should be a %s, but %s given';
167
            throw (new TypeConflictException(\sprintf($error, $type, $type->getDefinition(),
168
                $value->toString())))->throwsIn($type->getFile(), $value->getOffset());
169
        }
170
171
        /** @var Definition\InputDefinition $definition */
172
        $definition = $type->getDefinition();
@@ 187-191 (lines=5) @@
184
            /**
185
             * @validation <name: InputType = {nonExistentField: Value}>
186
             */
187
            if (! $definition->hasField($name)) {
188
                $error = 'Input field "%s" does not provided by %s, but %s given';
189
                throw (new TypeConflictException(\sprintf($error, $name, $type->getDefinition(),
190
                    $value->toString())))->throwsIn($type->getFile(), $value->getOffset());
191
            }
192
193
            $invocation->withArgument($name, $this->getValueOf($child, $definition->getField($name)));
194
        }
@@ 210-214 (lines=5) @@
207
        /**
208
         * @validation <name: Enum = "NotEnumValue">
209
         */
210
        if (! ($value instanceof ConstantValueNode)) {
211
            $error = 'Value of %s can be one of %s value, but %s given';
212
            throw (new TypeConflictException(\sprintf($error, $type, $type->getDefinition(),
213
                $value->toString())))->throwsIn($type->getFile(), $value->getOffset());
214
        }
215
216
        /** @var EnumDefinition $definition */
217
        $definition = $type->getDefinition();
@@ 224-228 (lines=5) @@
221
        /**
222
         * @validation <name: Enum = NonExistentValue>
223
         */
224
        if (! $definition->hasValue($name)) {
225
            $error = 'Enum %s does not provide value %s';
226
            throw (new TypeConflictException(\sprintf($error, $type->getDefinition(), $value->toString())))
227
                ->throwsIn($type->getFile(), $value->getOffset());
228
        }
229
230
        return $definition->getValue($name)->getValue();
231
    }