src/bbn/file/dir.php
public static function scan(string $dir, string $type = null, bool $hidden = false): array
   {
	   $all = [];
	   $dir = self::clean($dir);
	   $dirs = self::get_dirs($dir);
	   if ( \is_array($dirs) ){
	     if ( $type && (strpos($type, 'file') === 0) ){
	       $all = self::get_files($dir, false, $hidden);
	     }
	     else if ( $type && ((strpos($type, 'dir') === 0) || (strpos($type, 'fold') === 0)) ){
	       $all = $dirs;
	     }
	     else if ( $type ){
	       $all = array_filter(self::get_files($dir, false, $hidden), function($a)use($type){
	         $ext = bbn\str::file_ext($a);
	         return strtolower($ext) === strtolower($type);
	       });
	     }
	     else{
	       $files = self::get_files($dir, false, $hidden);
	       if ( \is_array($files) ){
	         $all = array_merge($dirs, $files);
	       }
	     }
	     foreach ( $dirs as $d ){
	       $all = array_merge(\is_array($all) ? $all : [], self::scan($d, $type, $hidden));
	     }
	   }
	   return $all;
	 }
public static function scan(string $dir, string $type = null, bool $hidden = false): array
   {
	   $all = [];
	   $dir = self::clean($dir);
	   $dirs = self::get_dirs($dir);
	   if ( \is_array($dirs) ){
	     if ( $type && (strpos($type, 'file') === 0) ){
	       $all = self::get_files($dir, false, $hidden);
	     }
	     else if ( $type && ((strpos($type, 'dir') === 0) || (strpos($type, 'fold') === 0)) ){
	       $all = $dirs;
	     }
	     else if ( $type ){
	       $all = array_filter(self::get_files($dir, false, $hidden), function($a)use($type){
	         $ext = bbn\str::file_ext($a);
	         return strtolower($ext) === strtolower($type);
	       });
	     }
	     else{
	       $files = self::get_files($dir, false, $hidden);
	       if ( \is_array($files) ){
	         $all = array_merge($dirs, $files);
	       }
	     }
	     foreach ( $dirs as $d ){
	       $all = array_merge(\is_array($all) ? $all : [], self::scan($d, $type, $hidden));
	     }
	   }
	   return $all;
	 }
public static function scan ( string $ dir , string $ type = null , bool $ hidden = false ) : array { $ all = [ ] ; $ dir = self :: clean ( $ dir ) ; $ dirs = self :: get_dirs ( $ dir ) ; if ( \ is_array ( $ dirs ) ) { if ( $ type && ( strpos ( $ type , 'file' ) === 0 ) ) { $ all = self :: get_files ( $ dir , false , $ hidden ) ; } else if ( $ type && ( ( strpos ( $ type , 'dir' ) === 0 ) || ( strpos ( $ type , 'fold' ) === 0 ) ) ) { $ all = $ dirs ; } else if ( $ type ) { $ all = array_filter ( self :: get_files ( $ dir , false , $ hidden ) , function ( $ a ) use ( $ type ) { $ ext = bbn \ str :: file_ext ( $ a ) ; return strtolower ( $ ext ) === strtolower ( $ type ) ; } ) ; } else { $ files = self :: get_files ( $ dir , false , $ hidden ) ; if ( \ is_array ( $ files ) ) { $ all = array_merge ( $ dirs , $ files ) ; } } foreach ( $ dirs as $ d ) { $ all = array_merge ( \ is_array ( $ all ) ? $ all : [ ] , self :: scan ( $ d , $ type , $ hidden ) ) ; } } return $ all ; }
Returns an array with all the content of the given directory.

@todo check the default value for $hidden

```php
\bbn\x::dump(\bbn\file\dir::scan("/home/data/test"));
// (array) ["/home/data/test/Folder", "/home/data/test/Folder_test/image.png"]
\bbn\x::dump(\bbn\file\dir::scan("/home/data/test", "", true));
// (array) ["/home/data/test/Folder", "/home/data/test/Folder_test/image.png", "/home/data/test/.doc.pdf"]
\bbn\x::dump(\bbn\file\dir::scan("/home/data/test", "dir"));
// (array) ["/home/data/test/Folder", "/home/data/test/Folder_test"]
\bbn\x::dump(\bbn\file\dir::scan("/home/data/test", "file"));
// (array) ["/home/data/test/Folder_test/image.png"]
\bbn\x::dump(\bbn\file\dir::scan("/home/data/test", "file", true));
// (array) ["/home/data/test/Folder_test/image.png", "/home/data/test/Folder/.doc.pdf"]
```

@param string $dir The directory's path.
@param string $type The type or the extension of item to return ('file', 'dir', 'php', default is both)
@param bool $hidden If set to true will include the hidden files/directories in the result
@return array
Returns an array with all the content of the given directory .