BrowscapPHP\BrowscapUpdater::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

Пример #1
0
 /**
  * @dataProvider userAgentDataProviderLite
  * @coversNothing
  *
  * @param string $userAgent
  * @param array  $expectedProperties
  *
  * @throws \Exception
  * @throws \BrowscapPHP\Exception
  *
  * @group intergration
  * @group useragenttest
  * @group lite
  */
 public function testUserAgentsLite($userAgent, $expectedProperties)
 {
     if (!is_array($expectedProperties) || !count($expectedProperties)) {
         self::markTestSkipped('Could not run test - no properties were defined to test');
     }
     static $updatedLiteCache = false;
     if (!$updatedLiteCache) {
         self::$browscapUpdater->getCache()->flush();
         self::$browscapUpdater->convertFile(self::$buildFolder . '/lite_php_browscap.ini');
         $updatedLiteCache = true;
     }
     $actualProps = (array) self::$browscap->getBrowser($userAgent);
     foreach ($expectedProperties as $propName => $propValue) {
         if (!self::$propertyHolder->isOutputProperty($propName)) {
             continue;
         }
         if (!self::$propertyHolder->isLiteModeProperty($propName)) {
             continue;
         }
         $propName = strtolower($propName);
         self::assertArrayHasKey($propName, $actualProps, 'Actual result does not have "' . $propName . '" property');
         self::assertSame($propValue, $actualProps[$propName], 'Expected actual "' . $propName . '" to be "' . $propValue . '" (was "' . $actualProps[$propName] . '"; used pattern: ' . $actualProps['browser_name_pattern'] . ')');
     }
 }
All Usage Examples Of BrowscapPHP\BrowscapUpdater::getCache