<commit_before><?php

/*
 * This file is part of the EcommitUtilBundle package.
 *
 * (c) E-commit <<EMAIL>>
 *
 * For the full copyright and license information, please view the LICENSE
 * file that was distributed with this source code.
 */

namespace Ecommit\UtilBundle\Cache;

use Zend\Cache\StorageFactory;

class Cache
{
    /**
     * @var Zend\Cache\Storage\Adapter 
     */
    protected $adapter;
    
    protected $automaticSerialization = true;
    
    public function __construct($options = array())
    {
        if (isset($options['automatic_serialization'])) {
            $this->automaticSerialization = $options['automatic_serialization'];
            unset($options['automatic_serialization']);
        }
        $this->adapter = StorageFactory::factory($options);
    }
    
    /**
     * Returns adapter
     * @return Zend\Cache\Storage\Adapter 
     */
    public function getAdapter()
    {
        return $this->adapter;
    }
    
    /**
     * Test if an item exists
     * 
     * @param  string $key
     * @return boolean
     * @throws \Zend\Cache\Exception
     */
    public function test($key)
    {
        return $this->adapter->hasItem($key);
    }
    
    /**
     * Get an item
     * 
     * @param  string $key
     * @return mixed Data on success and false on failure
     * @throws \Zend\Cache\Exception
     */
    public function load($key)
    {
        $data = $this->adapter->getItem($key, $success);

        if ($success && $this->automaticSerialization) {
            $data = @unserialize($data);
            <commit_msg>Remove @ before unserialize<commit_after><?php

/*
 * This file is part of the EcommitUtilBundle package.
 *
 * (c) E-commit <<EMAIL>>
 *
 * For the full copyright and license information, please view the LICENSE
 * file that was distributed with this source code.
 */

namespace Ecommit\UtilBundle\Cache;

use Zend\Cache\StorageFactory;

class Cache
{
    /**
     * @var Zend\Cache\Storage\Adapter 
     */
    protected $adapter;
    
    protected $automaticSerialization = true;
    
    public function __construct($options = array())
    {
        if (isset($options['automatic_serialization'])) {
            $this->automaticSerialization = $options['automatic_serialization'];
            unset($options['automatic_serialization']);
        }
        $this->adapter = StorageFactory::factory($options);
    }
    
    /**
     * Returns adapter
     * @return Zend\Cache\Storage\Adapter 
     */
    public function getAdapter()
    {
        return $this->adapter;
    }
    
    /**
     * Test if an item exists
     * 
     * @param  string $key
     * @return boolean
     * @throws \Zend\Cache\Exception
     */
    public function test($key)
    {
        return $this->adapter->hasItem($key);
    }
    
    /**
     * Get an item
     * 
     * @param  string $key
     * @return mixed Data on success and false on failure
     * @throws \Zend\Cache\Exception
     */
    public function load($key)
    {
        $data = $this->adapter->getItem($key, $success);

        if ($success && $this->automaticSerialization) {
            $data = unserialize($data);
            
{'fraction_non_alphanumeric': 0.1225134196400379, 'fraction_numerical': 0.0, 'mean_word_length': 2.2, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 23, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3253963', 'n_tokens_mistral': 896, 'n_tokens_neox': 879, 'n_words': 220}