protected function scanDirectory($path, $extensions)
    {
        if (is_file($path)) {
            $file = new \SplFileInfo($path);
            return array($this->getFileKey($file->getPath(), $file) => $file);
        }
        
        $files = array();
        $extensions = (array) $extensions;
        $iterator = new \RecursiveIteratorIterator(
            new \RecursiveDirectoryIterator(
                $path, 
                \FileSystemIterator::SKIP_DOTS 
                    | \FileSystemIterator::CURRENT_AS_FILEINFO)    
        );
        foreach ($iterator as $file) {
            if (in_array($file->getExtension(), $extensions)) {
                $files[$this->getFileKey($path, $file)] = $file;
            }
        }
        return $files;
    }
protected function scanDirectory($path, $extensions)
    {
        if (is_file($path)) {
            $file = new \SplFileInfo($path);
            return array($this->getFileKey($file->getPath(), $file) => $file);
        }
        
        $files = array();
        $extensions = (array) $extensions;
        $iterator = new \RecursiveIteratorIterator(
            new \RecursiveDirectoryIterator(
                $path, 
                \FileSystemIterator::SKIP_DOTS 
                    | \FileSystemIterator::CURRENT_AS_FILEINFO)    
        );
        foreach ($iterator as $file) {
            if (in_array($file->getExtension(), $extensions)) {
                $files[$this->getFileKey($path, $file)] = $file;
            }
        }
        return $files;
    }
protected function scanDirectory ( $ path , $ extensions ) { if ( is_file ( $ path ) ) { $ file = new \ SplFileInfo ( $ path ) ; return array ( $ this -> getFileKey ( $ file -> getPath ( ) , $ file ) => $ file ) ; } $ files = array ( ) ; $ extensions = ( array ) $ extensions ; $ iterator = new \ RecursiveIteratorIterator ( new \ RecursiveDirectoryIterator ( $ path , \ FileSystemIterator :: SKIP_DOTS | \ FileSystemIterator :: CURRENT_AS_FILEINFO ) ) ; foreach ( $ iterator as $ file ) { if ( in_array ( $ file -> getExtension ( ) , $ extensions ) ) { $ files [ $ this -> getFileKey ( $ path , $ file ) ] = $ file ; } } return $ files ; }
Scan a directory and return a list of files with matching extenstions

@param string $path Directory path to scan
@param string|array $extensions Match files with these extensions
Scan a directory and return a list of files with matching extenstions