public function getFiles(string $path, bool $isRecursive = false) : array
    {
        if (!$this->isDirectory($path)) {
            return [];
        }

        $files = [];
        $iter = new RecursiveIteratorIterator(
            new RecursiveDirectoryIterator($path, RecursiveDirectoryIterator::SKIP_DOTS),
            RecursiveIteratorIterator::SELF_FIRST,
            RecursiveIteratorIterator::CATCH_GET_CHILD
        );

        if (!$isRecursive) {
            $iter->setMaxDepth(0);
        }

        foreach ($iter as $path => $item) {
            if ($item->isFile()) {
                $files[] = $path;
            }
        }

        return $files;
    }
public function getFiles(string $path, bool $isRecursive = false) : array
    {
        if (!$this->isDirectory($path)) {
            return [];
        }

        $files = [];
        $iter = new RecursiveIteratorIterator(
            new RecursiveDirectoryIterator($path, RecursiveDirectoryIterator::SKIP_DOTS),
            RecursiveIteratorIterator::SELF_FIRST,
            RecursiveIteratorIterator::CATCH_GET_CHILD
        );

        if (!$isRecursive) {
            $iter->setMaxDepth(0);
        }

        foreach ($iter as $path => $item) {
            if ($item->isFile()) {
                $files[] = $path;
            }
        }

        return $files;
    }
public function getFiles ( string $ path , bool $ isRecursive = false ) : array { if ( ! $ this -> isDirectory ( $ path ) ) { return [ ] ; } $ files = [ ] ; $ iter = new RecursiveIteratorIterator ( new RecursiveDirectoryIterator ( $ path , RecursiveDirectoryIterator :: SKIP_DOTS ) , RecursiveIteratorIterator :: SELF_FIRST , RecursiveIteratorIterator :: CATCH_GET_CHILD ) ; if ( ! $ isRecursive ) { $ iter -> setMaxDepth ( 0 ) ; } foreach ( $ iter as $ path => $ item ) { if ( $ item -> isFile ( ) ) { $ files [ ] = $ path ; } } return $ files ; }
Gets all of the files at the input path

@param string $path The path to check
@param bool $isRecursive Whether or not we should recurse through child directories
@return array All of the files at the path
Gets all of the files at the input path