Code Duplication    Length = 37-39 lines in 2 locations

lib/Doctrine/ORM/Mapping/Driver/NewAnnotationDriver.php 1 location

@@ 418-454 (lines=37) @@
415
     *
416
     * @return Mapping\TableMetadata
417
     */
418
    private function convertTableAnnotationToTableMetadata(Annotation\Table $tableAnnot)
419
    {
420
        $table = new Mapping\TableMetadata();
421
422
        if (! empty($tableAnnot->name)) {
423
            $table->setName($tableAnnot->name);
424
        }
425
426
        if (! empty($tableAnnot->schema)) {
427
            $table->setSchema($tableAnnot->schema);
428
        }
429
430
        foreach ($tableAnnot->options as $optionName => $optionValue) {
431
            $table->addOption($optionName, $optionValue);
432
        }
433
434
        foreach ($tableAnnot->indexes as $indexAnnot) {
435
            $table->addIndex([
436
                'name'    => $indexAnnot->name,
437
                'columns' => $indexAnnot->columns,
438
                'unique'  => $indexAnnot->unique,
439
                'options' => $indexAnnot->options,
440
                'flags'   => $indexAnnot->flags,
441
            ]);
442
        }
443
444
        foreach ($tableAnnot->uniqueConstraints as $uniqueConstraintAnnot) {
445
            $table->addUniqueConstraint([
446
                'name'    => $uniqueConstraintAnnot->name,
447
                'columns' => $uniqueConstraintAnnot->columns,
448
                'options' => $uniqueConstraintAnnot->options,
449
                'flags'   => $uniqueConstraintAnnot->flags,
450
            ]);
451
        }
452
453
        return $table;
454
    }
455
456
    /**
457
     * @param Annotation\SqlResultSetMapping $resultSetMapping

lib/Doctrine/ORM/Mapping/Driver/AnnotationDriver.php 1 location

@@ 1079-1117 (lines=39) @@
1076
     *
1077
     * @return Mapping\TableMetadata
1078
     */
1079
    private function convertTableAnnotationToTableMetadata(
1080
        Annotation\Table $tableAnnot
1081
    ) : Mapping\TableMetadata
1082
    {
1083
        $table = new Mapping\TableMetadata();
1084
1085
        if (! empty($tableAnnot->name)) {
1086
            $table->setName($tableAnnot->name);
1087
        }
1088
1089
        if (! empty($tableAnnot->schema)) {
1090
            $table->setSchema($tableAnnot->schema);
1091
        }
1092
1093
        foreach ($tableAnnot->options as $optionName => $optionValue) {
1094
            $table->addOption($optionName, $optionValue);
1095
        }
1096
1097
        foreach ($tableAnnot->indexes as $indexAnnot) {
1098
            $table->addIndex([
1099
                'name'    => $indexAnnot->name,
1100
                'columns' => $indexAnnot->columns,
1101
                'unique'  => $indexAnnot->unique,
1102
                'options' => $indexAnnot->options,
1103
                'flags'   => $indexAnnot->flags,
1104
            ]);
1105
        }
1106
1107
        foreach ($tableAnnot->uniqueConstraints as $uniqueConstraintAnnot) {
1108
            $table->addUniqueConstraint([
1109
                'name'    => $uniqueConstraintAnnot->name,
1110
                'columns' => $uniqueConstraintAnnot->columns,
1111
                'options' => $uniqueConstraintAnnot->options,
1112
                'flags'   => $uniqueConstraintAnnot->flags,
1113
            ]);
1114
        }
1115
1116
        return $table;
1117
    }
1118
1119
    /**
1120
     * Parse the given JoinTable as JoinTableMetadata