folder.php ➔ requireSubfolder()   A
last analyzed

Complexity

Conditions 2
Paths 2

Size

Total Lines 5

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 2
nc 2
nop 1
dl 0
loc 5
rs 10
c 0
b 0
f 0
1
<?php
2
  function subFolder( $_dir = "./" ) {
3
    $temp = fetchInSubFolder($_dir, function() {
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