protected function _clearDirectory($path, $now, $threshold)
    {
        if (!is_dir($path)) {
            return;
        }
        $prefixLength = strlen($this->_config['prefix']);

        $dir = dir($path);
        while (($entry = $dir->read()) !== false) {
            if (substr($entry, 0, $prefixLength) !== $this->_config['prefix']) {
                continue;
            }

            try {
                $file = new SplFileObject($path . $entry, 'r');
            } catch (Exception $e) {
                continue;
            }

            if ($threshold) {
                $mtime = $file->getMTime();
                if ($mtime > $threshold) {
                    continue;
                }

                $expires = (int)$file->current();
                if ($expires > $now) {
                    continue;
                }
            }
            if ($file->isFile()) {
                $filePath = $file->getRealPath();
                $file = null;

                //@codingStandardsIgnoreStart
                @unlink($filePath);
                //@codingStandardsIgnoreEnd
            }
        }

        $dir->close();
    }
protected function _clearDirectory($path, $now, $threshold)
    {
        if (!is_dir($path)) {
            return;
        }
        $prefixLength = strlen($this->_config['prefix']);

        $dir = dir($path);
        while (($entry = $dir->read()) !== false) {
            if (substr($entry, 0, $prefixLength) !== $this->_config['prefix']) {
                continue;
            }

            try {
                $file = new SplFileObject($path . $entry, 'r');
            } catch (Exception $e) {
                continue;
            }

            if ($threshold) {
                $mtime = $file->getMTime();
                if ($mtime > $threshold) {
                    continue;
                }

                $expires = (int)$file->current();
                if ($expires > $now) {
                    continue;
                }
            }
            if ($file->isFile()) {
                $filePath = $file->getRealPath();
                $file = null;

                //@codingStandardsIgnoreStart
                @unlink($filePath);
                //@codingStandardsIgnoreEnd
            }
        }

        $dir->close();
    }
protected function _clearDirectory ( $ path , $ now , $ threshold ) { if ( ! is_dir ( $ path ) ) { return ; } $ prefixLength = strlen ( $ this -> _config [ 'prefix' ] ) ; $ dir = dir ( $ path ) ; while ( ( $ entry = $ dir -> read ( ) ) !== false ) { if ( substr ( $ entry , 0 , $ prefixLength ) !== $ this -> _config [ 'prefix' ] ) { continue ; } try { $ file = new SplFileObject ( $ path . $ entry , 'r' ) ; } catch ( Exception $ e ) { continue ; } if ( $ threshold ) { $ mtime = $ file -> getMTime ( ) ; if ( $ mtime > $ threshold ) { continue ; } $ expires = ( int ) $ file -> current ( ) ; if ( $ expires > $ now ) { continue ; } } if ( $ file -> isFile ( ) ) { $ filePath = $ file -> getRealPath ( ) ; $ file = null ; //@codingStandardsIgnoreStart @ unlink ( $ filePath ) ; //@codingStandardsIgnoreEnd } } $ dir -> close ( ) ; }
Used to clear a directory of matching files.

@param string $path The path to search.
@param int $now The current timestamp
@param int $threshold Any file not modified after this value will be deleted.
@return void
Used to clear a directory of matching files .