@@ 36-57 (lines=22) @@ | ||
33 | } |
|
34 | } |
|
35 | ||
36 | public function scan_dir( $root, $exclude = array() ) { |
|
37 | ||
38 | $filter = function ( $file, $key, $iterator ) use ( $exclude ) { |
|
39 | if ( $iterator->hasChildren() && ! in_array( $file->getFilename(), $exclude ) ) { |
|
40 | return true; |
|
41 | } |
|
42 | return $file->isFile(); |
|
43 | }; |
|
44 | ||
45 | $inner_iterator = new \RecursiveDirectoryIterator( $root, \RecursiveDirectoryIterator::SKIP_DOTS ); |
|
46 | ||
47 | $iterator = new \RecursiveIteratorIterator( |
|
48 | new \RecursiveCallbackFilterIterator( $inner_iterator, $filter ) |
|
49 | ); |
|
50 | ||
51 | $valid_extensions = array( 'php' ); |
|
52 | foreach ( $iterator as $file ) { |
|
53 | if ( in_array( strtolower( array_pop( explode( '.', $file ) ) ), $valid_extensions ) ) { |
|
54 | $this->scan_file( $root, $file ); |
|
55 | } |
|
56 | } |
|
57 | } |
|
58 | ||
59 | public function scan_file( $root, $file_path ) { |
|
60 | $file_path_relative = str_replace( $root, '', $file_path ); |
@@ 40-61 (lines=22) @@ | ||
37 | } |
|
38 | } |
|
39 | ||
40 | public function scan_dir( $root, $exclude = array() ) { |
|
41 | ||
42 | $filter = function ( $file, $key, $iterator ) use ( $exclude ) { |
|
43 | if ( $iterator->hasChildren() && ! in_array( $file->getFilename(), $exclude ) ) { |
|
44 | return true; |
|
45 | } |
|
46 | return $file->isFile(); |
|
47 | }; |
|
48 | ||
49 | $inner_iterator = new \RecursiveDirectoryIterator( $root, \RecursiveDirectoryIterator::SKIP_DOTS ); |
|
50 | ||
51 | $iterator = new \RecursiveIteratorIterator( |
|
52 | new \RecursiveCallbackFilterIterator( $inner_iterator, $filter ) |
|
53 | ); |
|
54 | ||
55 | $valid_extensions = array( 'php' ); |
|
56 | foreach ( $iterator as $file ) { |
|
57 | if ( in_array( strtolower( array_pop( explode( '.', $file ) ) ), $valid_extensions ) ) { |
|
58 | $this->scan_file( $root, $file ); |
|
59 | } |
|
60 | } |
|
61 | } |
|
62 | ||
63 | // public function scan_file( $root, $file_path ) { |
|
64 | // $file_path_relative = str_replace( $root, '', $file_path ); |