Passed
Push — master ( 998a95...21763d )
by Federico
02:41
created

folder.php ➔ fetchInSubFolder()   B

Complexity

Conditions 7
Paths 3

Size

Total Lines 13
Code Lines 10

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 7
eloc 10
c 1
b 0
f 0
nc 3
nop 2
dl 0
loc 13
rs 8.2222
1
<?php
2
	function subFolder( $_dir = "./" ) {
3
		$temp = fetchInSubFolder($_dir, function( $_file ) {
0 ignored issues
show
Unused Code introduced by
The parameter $_file is not used and could be removed.

This check looks from parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
4
			return true;
5
		});
6
		return $temp;
7
	}
8
	function subFolderFile( $_dir = "./" ) {
9
		$temp = fetchInSubFolder($_dir, function( $_file ) {
10
			return !is_dir($_file);
11
		});
12
		return $temp;
13
	}
14
	function subFolderDir( $_dir = "./" ) {
15
		$temp = fetchInSubFolder($_dir, function( $_file ) {
16
			return !is_file($_file);
17
		});
18
		return $temp;
19
	}
20
	function fetchInSubFolder( $_dir = "./", $_function) {
21
		$temp = [];
22
		if (is_dir($_dir)) {
23
				if ($dirOpened = opendir($_dir)) {
24
						while (($file = readdir($dirOpened)) !== false)
25
								if( ($file !='.')&&($file !='..') )
26
									if($_function($file))
27
										array_push($temp,$file);
28
						closedir($dirOpened);
29
				}
30
		}
31
		return $temp;
32
	}
33
	function requireSubfolder( $_dir = "./" ) {
34
		$temp = subFolderFile($_dir);
35
		foreach ($temp as $i)
36
			jRequire($_dir."/".$i);
37
	}
38
	function require_js( $_dir = "./" ) {
39
		$tempArray = [];
40
		$temp = subFolderFile($_dir);
41
		foreach ($temp as $i)
42
			array_push($tempArray, $_dir."/".$i);
43
		return $tempArray;
44
	}
45
?>
0 ignored issues
show
Best Practice introduced by
It is not recommended to use PHP's closing tag ?> in files other than templates.

Using a closing tag in PHP files that only contain PHP code is not recommended as you might accidentally add whitespace after the closing tag which would then be output by PHP. This can cause severe problems, for example headers cannot be sent anymore.

A simple precaution is to leave off the closing tag as it is not required, and it also has no negative effects whatsoever.

Loading history...
46