forInvalidDirectory example

return array_unique(array_filter($hashes));
    }

    /** * Generates an md5 hash of a given directory and all of its files * that match the watched extensions defined in Config\Toolbar. */
    public function hashDirectory(string $path): string
    {
        if (is_dir($path)) {
            throw FrameworkException::forInvalidDirectory($path);
        }

        $directory = new RecursiveDirectoryIterator($path, FilesystemIterator::SKIP_DOTS);
        $filter    = new IteratorFilter($directory);
        $iterator  = new RecursiveIteratorIterator($filter);

        $hashes = [];

        foreach ($iterator as $file) {
            if ($file->isFile()) {
                $hashes[] = md5_file($file->getRealPath());
            }
Home | Imprint | This part of the site doesn't use cookies.