public function getFolders($regex = null, $recursive = false)
    {
        //argument test
        Argument::i()
            //argument 1 must be a string
            ->test(1, 'string', 'null')
            //argument 2 must be a boolean
            ->test(2, 'bool');

        $this->absolute();

        $folders = array();

        if ($handle = opendir($this->data)) {
            //walk the directory
            while (false !== ($folder = readdir($handle))) {
                // If this is infact a directory
                //and if it matches the regex
                if ($folder != '.' && $folder != '..'
                      && filetype($this->data .'/'. $folder) == 'dir'
                    && (!$regex || preg_match($regex, $folder))) {
                    //add it
                    $folders[] = self::i($this->data . '/' . $folder);
                    if ($recursive) {
                        $subfolders = self::i($this->data.'/'.$folder);
                        $folders = array_merge($folders, $subfolders->getFolders($regex, $recursive));
                    }

                }
            }
            closedir($handle);
        }

        return $folders;
    }
public function getFolders($regex = null, $recursive = false)
    {
        //argument test
        Argument::i()
            //argument 1 must be a string
            ->test(1, 'string', 'null')
            //argument 2 must be a boolean
            ->test(2, 'bool');

        $this->absolute();

        $folders = array();

        if ($handle = opendir($this->data)) {
            //walk the directory
            while (false !== ($folder = readdir($handle))) {
                // If this is infact a directory
                //and if it matches the regex
                if ($folder != '.' && $folder != '..'
                      && filetype($this->data .'/'. $folder) == 'dir'
                    && (!$regex || preg_match($regex, $folder))) {
                    //add it
                    $folders[] = self::i($this->data . '/' . $folder);
                    if ($recursive) {
                        $subfolders = self::i($this->data.'/'.$folder);
                        $folders = array_merge($folders, $subfolders->getFolders($regex, $recursive));
                    }

                }
            }
            closedir($handle);
        }

        return $folders;
    }
public function getFolders ( $ regex = null , $ recursive = false ) { //argument test Argument :: i ( ) //argument 1 must be a string -> test ( 1 , 'string' , 'null' ) //argument 2 must be a boolean -> test ( 2 , 'bool' ) ; $ this -> absolute ( ) ; $ folders = array ( ) ; if ( $ handle = opendir ( $ this -> data ) ) { //walk the directory while ( false !== ( $ folder = readdir ( $ handle ) ) ) { // If this is infact a directory //and if it matches the regex if ( $ folder != '.' && $ folder != '..' && filetype ( $ this -> data . '/' . $ folder ) == 'dir' && ( ! $ regex || preg_match ( $ regex , $ folder ) ) ) { //add it $ folders [ ] = self :: i ( $ this -> data . '/' . $ folder ) ; if ( $ recursive ) { $ subfolders = self :: i ( $ this -> data . '/' . $ folder ) ; $ folders = array_merge ( $ folders , $ subfolders -> getFolders ( $ regex , $ recursive ) ) ; } } } closedir ( $ handle ) ; } return $ folders ; }
Returns a list of folders given the path and optionally the regular expression

@param string|null $regex     Regular expression to match folders against
@param bool        $recursive To recursively look in folders

@return array
Returns a list of folders given the path and optionally the regular expression