Code Duplication    Length = 8-8 lines in 2 locations

src/Chamilo/CourseBundle/Component/CourseCopy/CourseRestorer.php 2 locations

@@ 584-591 (lines=8) @@
581
                        case FILE_RENAME:
582
                            $i = 1;
583
                            $ext = explode('.', basename($document->path));
584
                            if (count($ext) > 1) {
585
                                $ext = array_pop($ext);
586
                                $file_name_no_ext = substr($document->path, 0, - (strlen($ext) + 1));
587
                                $ext = '.'.$ext;
588
                            } else {
589
                                $ext = '';
590
                                $file_name_no_ext = $document->path;
591
                            }
592
                            $new_file_name = $file_name_no_ext.'_'.$i.$ext;
593
                            $file_exists = file_exists($path.$new_file_name);
594
                            while ($file_exists) {
@@ 992-999 (lines=8) @@
989
                        case FILE_RENAME:
990
                            $i = 1;
991
                            $ext = explode('.', basename($document->path));
992
                            if (count($ext) > 1) {
993
                                $ext = array_pop($ext);
994
                                $file_name_no_ext = substr($document->path, 0, - (strlen($ext) + 1));
995
                                $ext = '.'.$ext;
996
                            } else {
997
                                $ext = '';
998
                                $file_name_no_ext = $document->path;
999
                            }
1000
1001
                            $new_file_name = $file_name_no_ext.'_'.$i.$ext;
1002
                            $file_exists = file_exists($path.$new_file_name);