protected function checkConditions($cacheFile, array $conditions = array())
    {
        // Implicit condition: the cache file should exist
        if (!file_exists($cacheFile)) {
            return false;
        }

        foreach ($conditions as $type => $value) {
            switch ($type) {
            case 'maxage':
            case 'max-age':
                // Return false if the file is older than $value
                $age = time() - filemtime($cacheFile);
                if ($age > $value) {
                    return false;
                }
                break;
            case 'younger-than':
            case 'youngerthan':
                // Return false if the file is older than the file $value, or the files $value
                $check = function($filename) use ($cacheFile) {
                    return !file_exists($filename) || filemtime($cacheFile) < filemtime($filename);
                };

                if (!is_array($value)) {
                    if (!$this->isRemote($value) && $check($value)) {
                        return false;
                    }
                } else {
                    foreach ($value as $file) {
                        if (!$this->isRemote($file) && $check($file)) {
                            return false;
                        }
                    }
                }
                break;
            default:
                throw new \Exception('Cache condition '.$type.' not supported');
            }
        }

        return true;
    }
protected function checkConditions($cacheFile, array $conditions = array())
    {
        // Implicit condition: the cache file should exist
        if (!file_exists($cacheFile)) {
            return false;
        }

        foreach ($conditions as $type => $value) {
            switch ($type) {
            case 'maxage':
            case 'max-age':
                // Return false if the file is older than $value
                $age = time() - filemtime($cacheFile);
                if ($age > $value) {
                    return false;
                }
                break;
            case 'younger-than':
            case 'youngerthan':
                // Return false if the file is older than the file $value, or the files $value
                $check = function($filename) use ($cacheFile) {
                    return !file_exists($filename) || filemtime($cacheFile) < filemtime($filename);
                };

                if (!is_array($value)) {
                    if (!$this->isRemote($value) && $check($value)) {
                        return false;
                    }
                } else {
                    foreach ($value as $file) {
                        if (!$this->isRemote($file) && $check($file)) {
                            return false;
                        }
                    }
                }
                break;
            default:
                throw new \Exception('Cache condition '.$type.' not supported');
            }
        }

        return true;
    }
protected function checkConditions ( $ cacheFile , array $ conditions = array ( ) ) { // Implicit condition: the cache file should exist if ( ! file_exists ( $ cacheFile ) ) { return false ; } foreach ( $ conditions as $ type => $ value ) { switch ( $ type ) { case 'maxage' : case 'max-age' : // Return false if the file is older than $value $ age = time ( ) - filemtime ( $ cacheFile ) ; if ( $ age > $ value ) { return false ; } break ; case 'younger-than' : case 'youngerthan' : // Return false if the file is older than the file $value, or the files $value $ check = function ( $ filename ) use ( $ cacheFile ) { return ! file_exists ( $ filename ) || filemtime ( $ cacheFile ) < filemtime ( $ filename ) ; } ; if ( ! is_array ( $ value ) ) { if ( ! $ this -> isRemote ( $ value ) && $ check ( $ value ) ) { return false ; } } else { foreach ( $ value as $ file ) { if ( ! $ this -> isRemote ( $ file ) && $ check ( $ file ) ) { return false ; } } } break ; default : throw new \ Exception ( 'Cache condition ' . $ type . ' not supported' ) ; } } return true ; }
Checks that the cache conditions are respected

@param string $cacheFile the cache file
@param array $conditions an array of conditions to check
@return bool
@throws \Exception
Checks that the cache conditions are respected