BrowscapPHP\Cache\BrowscapCache::setItem PHP Method

setItem() public method

save the content into an php file
public setItem ( string $cacheId, mixed $content, boolean $withVersion = true ) : boolean
$cacheId string The cache id
$content mixed The content to store
$withVersion boolean
return boolean whether the file was correctly written to the disk
    public function setItem($cacheId, $content, $withVersion = true)
    {
        // Get the whole PHP code
        $data = ['content' => serialize($content)];
        if ($withVersion) {
            $cacheId .= '.' . $this->getVersion();
        }
        // Save and return
        return $this->cache->setItem($cacheId, $data);
    }

Usage Example

 public function testType()
 {
     $adapter = new Memory();
     $cache = new BrowscapCache($adapter);
     $this->assertNull($cache->getType());
     $cache->setItem('browscap.type', 'LITE', false);
     $this->assertEquals('LITE', $cache->getType());
 }