<commit_before><?php
/**
 * Widget Framework
 *
 * @copyright   Copyright (c) 2008-2012 <NAME>
 * @license     http://www.opensource.org/licenses/apache2.0.php Apache License
 */

namespace Widget;

/**
 * Session
 *
 * @package     Widget
 * @author      <NAME> <<EMAIL>>
 */
class Session extends ArrayWidget
{
    /**
     * Current namespace to store session data
     *
     * @var string
     */
    protected $_namespace;

    /**
     * Whether session started
     *
     * @var string
     */
    protected $_started = false;

    /**
     * @var array           Options
     *
     *      -- namespace    namespace to store session data
     *
     *      -- autoStart    whether auto start session when object construct
     *
     * @see http://php.net/manual/en/session.configuration.php
     */
    public $options = array(
        'namespace'         => 'qwin',
        'autoStart'         => true,
        'cache_limiter'     => 'private_no_expire, must-revalidate',
        'cookie_lifetime'   => 86400,
        'cache_expire'      => 86400,
    );

    public function __construct($options = null)
    {
        // merge options
        $options = (array) $options + $this->options;
        $this->options = &$options;

        // init all options
        $this->option($options);

        if ($options['autoStart']) {
            $this->start();
        }
    }

    /**
     * Get or set options
     *
     * @param  mixed $name
     * @param  mixed $value
     * @return mixed
     */
    public function option($name = null, $value = null)
    {
        if (2 == func_num_args() && (is_string($name) || is_int($name))) {
            if ('name' == $name || false !== strpos($name, '_')) {
                ini_set('session.' . $name, $value);
            }
            // set option
            return parent::option($name, $value);
        }

        return parent::option($name);
    }
<commit_msg>added __invoke method for session widget<commit_after><?php
/**
 * Widget Framework
 *
 * @copyright   Copyright (c) 2008-2012 <NAME>
 * @license     http://www.opensource.org/licenses/apache2.0.php Apache License
 */

namespace Widget;

/**
 * Session
 *
 * @package     Widget
 * @author      <NAME> <<EMAIL>>
 */
class Session extends ArrayWidget
{
    /**
     * Current namespace to store session data
     *
     * @var string
     */
    protected $_namespace;

    /**
     * Whether session started
     *
     * @var string
     */
    protected $_started = false;

    /**
     * @var array           Options
     *
     *      -- namespace    namespace to store session data
     *
     *      -- autoStart    whether auto start session when object construct
     *
     * @see http://php.net/manual/en/session.configuration.php
     */
    public $options = array(
        'namespace'         => 'widget',
        'autoStart'         => true,
        'cache_limiter'     => 'private_no_expire, must-revalidate',
        'cookie_lifetime'   => 86400,
        'cache_expire'      => 86400,
    );

    public function __construct($options = null)
    {
        // merge options
        $options = (array) $options + $this->options;
        $this->options = &$options;

        // init all options
        $this->option($options);

        if ($options['autoStart']) {
            $this->start();
        }
    }

    /**
     * Get or set options
     *
     * @param  mixed $name
     * @param  mixed $value
     * @return mixed
     */
    public function option($name = null, $value = null)
    {
        if (2 == func_num_args() && (is_string($name) || is_int($name))) {
            if ('name' == $name || false !== strpos($name, '_')) {
                ini_set('session.' . $name, $value);
            }
            // set option
            return parent::option($name, $value);
        }

        return parent::option($name);
    }
    
    /**
     * Return session value
     *
     * @param  string $name    The parameter name
     * @param  mixed  $default The default parameter value if the parameter does not exist
     * @return mixed  The parameter value
     */
    public function __invoke($name, $default = null)
    {
        return isset($this->data[$name]) ? $this->data[$name] : $default;
    }

{'fraction_non_alphanumeric': 0.138555633968478, 'fraction_numerical': 0.009880028228652082, 'mean_word_length': 1.7718383311603652, 'pattern_counts': {'":': 0, '<': 13, '<?xml version=': 0, '>': 31, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, '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': '79054', 'n_tokens_mistral': 1263, 'n_tokens_neox': 1217, 'n_words': 305}