Completed
Branch 2.0.0 (814c19)
by Jimmy
03:05
created

Include_Util   A

Complexity

Total Complexity 9

Size/Duplication

Total Lines 35
Duplicated Lines 25.71 %

Coupling/Cohesion

Components 0
Dependencies 1

Importance

Changes 0
Metric Value
dl 9
loc 35
rs 10
c 0
b 0
f 0
wmc 9
lcom 0
cbo 1

How to fix   Duplicated Code   

Duplicated Code

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
2
/**
3
 * Gestion des inclusions.
4
 *
5
 * @author Eoxia <[email protected]>
6
 * @since 0.1.0
7
 * @version 1.0.0
8
 * @copyright 2015-2018 Eoxia
9
 * @package EO_Framework\Core\Util
10
 */
11
12
namespace eoxia;
13
14
if ( ! defined( 'ABSPATH' ) ) {
15
	exit;
16
}
17
18
if ( ! class_exists( '\eoxia\Include_Util' ) ) {
19
	/**
20
	 * Gestion des inclusions.
21
	 */
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