AssetCompress\Shell\AssetCompressShell::_clearPath PHP Method

_clearPath() protected method

Clear a path of build targets.
protected _clearPath ( string $path, array $themes, array $targets ) : void
$path string The root path to clear.
$themes array The themes to clear.
$targets array The build targets to clear.
return void
    protected function _clearPath($path, $themes, $targets)
    {
        if (!file_exists($path)) {
            return;
        }
        $dir = new DirectoryIterator($path);
        foreach ($dir as $file) {
            $name = $base = $file->getFilename();
            if (in_array($name, ['.', '..'])) {
                continue;
            }
            // timestamped files.
            if (preg_match('/^(.*)\\.v\\d+(\\.[a-z]+)$/', $name, $matches)) {
                $base = $matches[1] . $matches[2];
            }
            // themed files
            foreach ($themes as $theme) {
                if (strpos($base, $theme) === 0 && strpos($base, '-') !== false) {
                    list($themePrefix, $base) = explode('-', $base);
                }
            }
            if (in_array($base, $targets)) {
                $this->_io->verbose(' - Deleting ' . $path . $name);
                unlink($path . $name);
                continue;
            }
        }
    }