isDot() === true || $file->isFile() === false) { continue; } $extension = pathinfo($file->getPathname(), PATHINFO_EXTENSION); if (strtolower($extension) !== 'svg') { continue; } $files[$file->getBasename()] = $file->getMTime(); } // We must use ksort for sort the array by filename (the DirectoryIterator have his self sort :-)), in PHP 5.3, we can use GlobIterator directly ksort($files); $cache = ' $time) { $cache .= '"'.str_replace('"', '\"', $name).'" => '.$time.', '; } $cache .= ');'; // if file wrinting fail, throw an Exception if (file_put_contents(self::$filename, $cache) === false) { throw new Exception('Impossible to write in the cache file : "'.self::$filename.'"'); } } /** * Return the last numeric key of the cache array * * @access public * @static * @return integer the last numeric key of the cache array */ public static function getLastId() { if (self::$cache === null) { self::getCache(); } return (count(self::$cache) - 1); } /** * Return the strip with the numeric key of the cache * * @access public * @static * @return Strip The strip wanted */ public static function getStrip($id = 0) { $last_id = self::getLastId(); // if the id of strip isn't valid, return a new strip if ($last_id === -1 || $id > $last_id) { return new Strip(); } $cache_iterator = new ArrayIterator(self::$cache); $cache_iterator->seek($id); return Strip::getCache($cache_iterator->key()); } }