Total Complexity | 7 |
Total Lines | 42 |
Duplicated Lines | 0 % |
Changes | 0 |
1 | <?php |
||
8 | class scan |
||
9 | { |
||
10 | public static $static = null; |
||
11 | public static $opt; |
||
12 | |||
13 | public function __construct($opt = []) |
||
14 | { |
||
15 | self::$opt = $opt; |
||
16 | } |
||
17 | |||
18 | public static function getStatic() |
||
19 | { |
||
20 | if (null === self::$static) { |
||
21 | self::$static = new self(self::$opt); |
||
22 | } |
||
23 | |||
24 | return self::$static; |
||
25 | } |
||
26 | |||
27 | public static function scanAllFiles($dir, $exclude = '/^(.{1,2}|\.htaccess)$/s') |
||
28 | { |
||
29 | $di = new RecursiveDirectoryIterator($dir); |
||
30 | $result = []; |
||
31 | foreach (new RecursiveIteratorIterator($di) as $filename => $file) { |
||
32 | $basename = basename($filename); |
||
|
|||
33 | if (preg_match($exclude, $basename)) { |
||
34 | continue; |
||
35 | } |
||
36 | $b['path'] = realpath($filename); |
||
37 | $b['data'] = \Filemanager\file::get(realpath($filename), true); |
||
38 | $b['folder'] = dirname(realpath($filename)); |
||
39 | $b['filename'] = $basename; |
||
40 | $b['size'] = $file->getSize(); |
||
41 | $result[] = $b; |
||
42 | } |
||
43 | |||
44 | return (array) $result; |
||
45 | } |
||
46 | |||
47 | public static function scandir($dir) |
||
50 | } |
||
51 | } |
||
52 |