public static function rmdir( $dirPath, $force = false )
    {
        $_path = rtrim( $dirPath ) . DIRECTORY_SEPARATOR;

        if ( !$force )
        {
            return rmdir( $_path );
        }

        if ( !is_dir( $_path ) )
        {
            throw new \InvalidArgumentException( '"' . $_path . '" is not a directory or bogus in some other way.' );
        }

        $_files = glob( $_path . '*', GLOB_MARK );

        foreach ( $_files as $_file )
        {
            if ( is_dir( $_file ) )
            {
                static::rmdir( $_file, true );
            }
            else
            {
                unlink( $_file );
            }
        }

        return rmdir( $_path );
    }
public static function rmdir( $dirPath, $force = false )
    {
        $_path = rtrim( $dirPath ) . DIRECTORY_SEPARATOR;

        if ( !$force )
        {
            return rmdir( $_path );
        }

        if ( !is_dir( $_path ) )
        {
            throw new \InvalidArgumentException( '"' . $_path . '" is not a directory or bogus in some other way.' );
        }

        $_files = glob( $_path . '*', GLOB_MARK );

        foreach ( $_files as $_file )
        {
            if ( is_dir( $_file ) )
            {
                static::rmdir( $_file, true );
            }
            else
            {
                unlink( $_file );
            }
        }

        return rmdir( $_path );
    }
public static function rmdir ( $ dirPath , $ force = false ) { $ _path = rtrim ( $ dirPath ) . DIRECTORY_SEPARATOR ; if ( ! $ force ) { return rmdir ( $ _path ) ; } if ( ! is_dir ( $ _path ) ) { throw new \ InvalidArgumentException ( '"' . $ _path . '" is not a directory or bogus in some other way.' ) ; } $ _files = glob ( $ _path . '*' , GLOB_MARK ) ; foreach ( $ _files as $ _file ) { if ( is_dir ( $ _file ) ) { static :: rmdir ( $ _file , true ) ; } else { unlink ( $ _file ) ; } } return rmdir ( $ _path ) ; }
rmdir function with force

@param string $dirPath
@param bool   $force If true, non-empty directories will be deleted

@return bool
@throws \InvalidArgumentException
rmdir function with force