Duplicate code is one of the most pungent code smells. A rule that is often used is to re-structure code once it is duplicated in three or more places.
Common duplication problems, and corresponding solutions are:
| 1 | <?php |
||
| 22 | class Include_Util extends \eoxia\Singleton_Util { |
||
| 23 | /** |
||
| 24 | * Le constructeur obligatoirement pour utiliser la classe \eoxia\Singleton_Util |
||
| 25 | * |
||
| 26 | * @since 0.1.0 |
||
| 27 | * @version 1.0.0 |
||
| 28 | * |
||
| 29 | * @return void |
||
| 30 | */ |
||
| 31 | protected function construct() {} |
||
| 32 | |||
| 33 | /** |
||
| 34 | * Récupères les fichiers dans le dossier $folder_path |
||
| 35 | * |
||
| 36 | * @since 0.1.0 |
||
| 37 | * @version 1.0.0 |
||
| 38 | * |
||
| 39 | * @param string $folder_path Le chemin du dossier. |
||
| 40 | * @return void |
||
| 41 | */ |
||
| 42 | public function in_folder( $folder_path ) { |
||
| 43 | $list_file_name = scandir( $folder_path ); |
||
| 44 | |||
| 45 | if ( ! empty( $list_file_name ) ) { |
||
| 46 | foreach ( $list_file_name as $file_name ) { |
||
| 47 | if ( '.' !== $file_name && '..' !== $file_name && 'index.php' !== $file_name && '.git' !== $file_name && 'README.md' !== $file_name ) { |
||
| 48 | |||
| 49 | $file_path = realpath( $folder_path . $file_name ); |
||
| 50 | $file_success = require_once( $file_path ); |
||
| 51 | } |
||
| 52 | } |
||
| 53 | } |
||
| 54 | |||
| 55 | } |
||
| 56 | } |
||
| 57 | } // End if(). |
||
| 58 |