* @license http://www.gnu.org/licenses/gpl-2.0.html */ namespace Kirby\Plugins\Typography; use Cache\Driver\File as FileCache; use Dir; use F; class Cache { protected $cacheRoot; protected $driver; protected function __construct() { $this->cacheRoot = kirby()->roots()->cache() . DS . 'plugins' . DS . 'typography'; if (!f::exists($this->cacheRoot)) { dir::make($this->cacheRoot); } $this->driver = new FileCache($this->cacheRoot); } public static function instance() { static $instance; return $instance ?: $instance = new self(); } public function driver() { return $this->driver; } public function root() { return $this->cacheRoot; } public function status() { return [ 'size' => dir::size($this->cacheRoot), 'files' => sizeof(dir::read($this->cacheRoot)), ]; } public function __call($name, $arguments) { return call_user_func_array([$this->driver, $name], $arguments); } }