BrowscapPHP\Browscap::getCache PHP Метод

getCache() публичный Метод

Gets a cache instance
public getCache ( ) : BrowscapPHP\Cache\BrowscapCacheInterface
Результат BrowscapPHP\Cache\BrowscapCacheInterface
    public function getCache()
    {
        if (null === $this->cache) {
            $cacheDirectory = __DIR__ . '/../resources/';
            $cacheAdapter = new File([File::DIR => $cacheDirectory]);
            $this->cache = new BrowscapCache($cacheAdapter);
        }
        return $this->cache;
    }

Usage Example

 public function __construct(Browscap $parser, $expectedType = '')
 {
     $this->parser = $parser;
     if ($parser->getCache()->getType() === null) {
         throw new InvalidArgumentException('You need to warm-up the cache first to use this provider');
     }
     if ($expectedType !== $parser->getCache()->getType()) {
         throw new InvalidArgumentException('Expected the "' . $expectedType . '" data file. Instead got the "' . $parser->getCache()->getType() . '" data file');
     }
 }
All Usage Examples Of BrowscapPHP\Browscap::getCache