Code Duplication    Length = 30-30 lines in 2 locations

src/Psalm/Internal/Type/TypeParser.php 2 locations

@@ 266-295 (lines=30) @@
263
                );
264
            }
265
266
            if ($generic_type_value === 'key-of') {
267
                $param_name = (string) $generic_params[0];
268
269
                if (isset($template_type_map[$param_name])) {
270
                    $defining_class = array_keys($template_type_map[$param_name])[0];
271
272
                    return new Atomic\TTemplateKeyOf(
273
                        $param_name,
274
                        $defining_class,
275
                        $template_type_map[$param_name][$defining_class][0]
276
                    );
277
                }
278
279
                $param_union_types = array_values($generic_params[0]->getAtomicTypes());
280
281
                if (count($param_union_types) > 1) {
282
                    throw new TypeParseTreeException('Union types are not allowed in key-of type');
283
                }
284
285
                if (!$param_union_types[0] instanceof Atomic\TScalarClassConstant) {
286
                    throw new TypeParseTreeException(
287
                        'Untemplated key-of param ' . $param_name . ' should be a class constant'
288
                    );
289
                }
290
291
                return new Atomic\TKeyOfClassConstant(
292
                    $param_union_types[0]->fq_classlike_name,
293
                    $param_union_types[0]->const_name
294
                );
295
            }
296
297
            if ($generic_type_value === 'value-of') {
298
                $param_name = (string) $generic_params[0];
@@ 297-326 (lines=30) @@
294
                );
295
            }
296
297
            if ($generic_type_value === 'value-of') {
298
                $param_name = (string) $generic_params[0];
299
300
                if (isset($template_type_map[$param_name])) {
301
                    $defining_class = array_keys($template_type_map[$param_name])[0];
302
303
                    return new Atomic\TTemplateKeyOf(
304
                        $param_name,
305
                        $defining_class,
306
                        $template_type_map[$param_name][$defining_class][0]
307
                    );
308
                }
309
310
                $param_union_types = array_values($generic_params[0]->getAtomicTypes());
311
312
                if (count($param_union_types) > 1) {
313
                    throw new TypeParseTreeException('Union types are not allowed in value-of type');
314
                }
315
316
                if (!$param_union_types[0] instanceof Atomic\TScalarClassConstant) {
317
                    throw new TypeParseTreeException(
318
                        'Untemplated value-of param ' . $param_name . ' should be a class constant'
319
                    );
320
                }
321
322
                return new Atomic\TValueOfClassConstant(
323
                    $param_union_types[0]->fq_classlike_name,
324
                    $param_union_types[0]->const_name
325
                );
326
            }
327
328
            if (isset(TypeTokenizer::PSALM_RESERVED_WORDS[$generic_type_value])
329
                && $generic_type_value !== 'self'