public function isEmpty($filter = null): bool
    {
        if (! $this->exists()) {
            throw new DirectoryException("Directory {dir} does not exist", array(
                'dir' => $this->path
            ));
        }
        
        $iter = new \DirectoryIterator($this->path);
        while ($iter->valid()) {
            if (! $iter->isDot() && ($filter === null || ! preg_match("/$filter/", $iter->getFilename()))) {
                return false;
            }
            $iter->next();
        }
        
        return true;
    }