<commit_before><?php

namespace HumusMvc\View;

use HumusMvc\Exception;
use HumusMvc\View\HelperPluginManager;
use Zend_Loader_PluginLoader_Interface as PluginLoader;
use Zend_View;
use Zend_View_Interface as ViewInterface;
use Zend_View_Exception as ViewException;

/**
 * @category   Humus
 * @package    HumusMvc
 */
class View implements ViewInterface
{

    /**
     * @var HelperPluginManager
     */
    protected $_helpers;
    /**
     * @var Zend_View
     */
    protected $_view;

    /**
     * Constructor
     */
    public function __construct()
    {
        $this->_view = new Zend_View();
    }

    /**
     * Get helper plugin manager instance
     *
     * @return HelperPluginManager
     */
    public function getHelperPluginManager()
    {
        if (null === $this->_helpers) {
            $this->setHelperPluginManager(new HelperPluginManager());
        }
        return $this->_helpers;
    }

    /**
     * Set helper plugin manager instance
     *
     * @param  string|HelperPluginManager $helpers
     * @return View
     * @throws Exception\InvalidArgumentException
     */
    public function setHelperPluginManager($helpers)
    {
        if (is_string($helpers)) {
            if (!class_exists($helpers)) {
                throw new Exception\InvalidArgumentException(sprintf(
                    'Invalid helper helpers class provided (%s)',
                    $helpers
                ));
            }
            $helpers = new $helpers();
        }
        if (!$helpers instanceof HelperPluginManager) {
            throw new Exception\InvalidArgumentException(sprintf(
                'Helper helpers must extend HumusMvc\View\HelperPluginManager; got type "%s" instead',
                (is_object($helpers) ? get_class($helpers) : gettype($helpers))
            ));
        }
        $helpers->setView($this);
        $this->_helpers = $helpers;

        return $this;
    }

    /**
     * Return the template engine object, if any
     *
     * If using a third-party template engine, such as Smarty, patTemplate,
     * phplib, etc, return the template engine object. Useful for calling
     * methods on these objects, such as for setting filters, modifiers, etc.
     *
     * @return mixed
     */
    public function getEngine()
    {
        return $this->_view->getEngine();
    }

    /**
     * Set the path to find the view script used by render()
     *
     * @param string|array The directory (-ies) to set as the path. Note that
     * the concrete view implentation may not necessarily support multiple
     * directories.
     * @return View
     */
    public function setScriptPath($path)
    {
        $this->_view->setScriptPath($path);
        return $this;
    }

    /**
     * Retrieve all view script paths
     *
     * @return array
     */
    public function getScriptPaths()
    {
        return $this->_view->getScriptPaths();
    }

    /**
     * Set a base path to all view resources
     *
     * @param  string $path
     * @param  string $classPrefix
     * @return View
     */
    public function setBasePath($path, $classPrefix = 'Zend_View')
    {
        $this->_view->setBasePath($path, $classPrefix);
        return $this;
    }

    /**
     * Add an additional path to view resources
     *
     * @param  string $path
     * @param  string $classPrefix
     * @return View
     */
    public function addBasePath($path, $classPrefix = 'Zend_View')
    {
        $this->_view->addBasePath($path, $classPrefix);
        return $this;
    }

    /**
     * Assign a variable to the view
     *
     * @param string $key The variable name.
     * @param mixed $val The variable value.
     * @return void
     */
    public function __set($key, $val)
    {
        $this->_view->__set($key, $val);
    }

    /**
     * Allows testing with empty() and isset() to work<commit_msg>added __get(tlog) to HumusMvc\View\View<commit_after><?php

namespace HumusMvc\View;

use HumusMvc\Exception;
use HumusMvc\View\HelperPluginManager;
use Zend_Loader_PluginLoader_Interface as PluginLoader;
use Zend_View;
use Zend_View_Interface as ViewInterface;
use Zend_View_Exception as ViewException;

/**
 * @category   Humus
 * @package    HumusMvc
 */
class View implements ViewInterface
{

    /**
     * @var HelperPluginManager
     */
    protected $_helpers;
    /**
     * @var Zend_View
     */
    protected $_view;

    /**
     * Constructor
     *
     * @param array $config Configuration key-value pairs.
     */
    public function __construct($config = array())
    {
        $this->_view = new Zend_View($config);
    }

    /**
     * Get helper plugin manager instance
     *
     * @return HelperPluginManager
     */
    public function getHelperPluginManager()
    {
        if (null === $this->_helpers) {
            $this->setHelperPluginManager(new HelperPluginManager());
        }
        return $this->_helpers;
    }

    /**
     * Set helper plugin manager instance
     *
     * @param  string|HelperPluginManager $helpers
     * @return View
     * @throws Exception\InvalidArgumentException
     */
    public function setHelperPluginManager($helpers)
    {
        if (is_string($helpers)) {
            if (!class_exists($helpers)) {
                throw new Exception\InvalidArgumentException(sprintf(
                    'Invalid helper helpers class provided (%s)',
                    $helpers
                ));
            }
            $helpers = new $helpers();
        }
        if (!$helpers instanceof HelperPluginManager) {
            throw new Exception\InvalidArgumentException(sprintf(
                'Helper helpers must extend HumusMvc\View\HelperPluginManager; got type "%s" instead',
                (is_object($helpers) ? get_class($helpers) : gettype($helpers))
            ));
        }
        $helpers->setView($this);
        $this->_helpers = $helpers;

        return $this;
    }

    /**
     * Return the template engine object, if any
     *
     * If using a third-party template engine, such as Smarty, patTemplate,
     * phplib, etc, return the template engine object. Useful for calling
     * methods on these objects, such as for setting filters, modifiers, etc.
     *
     * @return mixed
     */
    public function getEngine()
    {
        return $this->_view->getEngine();
    }

    /**
     * Set the path to find the view script used by render()
     *
     * @param string|array The directory (-ies) to set as the path. Note that
     * the concrete view implentation may not necessarily support multiple
     * directories.
     * @return View
     */
    public function setScriptPath($path)
    {
        $this->_view->setScriptPath($path);
        return $this;
    }

    /**
     * Retrieve all view script paths
     *
     * @return array
     */
    public function getScriptPaths()
    {
        return $this->_view->getScriptPaths();
    }

    /**
     * Set a base path to all view resources
     *
     * @param  string $path
     * @param  string $classPrefix
     * @return View
     */
    public function setBasePath($path, $classPrefix = 'Zend_View')
    {
        $this->_view->setBasePath($path, $classPrefix);
        return $this;
    }

    /**
     * Add an additional path to view resources
     *
     * @param  string $path
     * @param  string $classPrefix
     * @return View
     */
    public function addBasePath($path, $classPrefix = 'Zend_View')
    {
        $this->_view->addBasePath($path, $classPrefix);
        return $this;
    }

    /**
     * Prevent E_NOTICE for nonexistent values
     *
     * If {@link strictVars()} is on, raises a notice.
     *
     * @param  string $key
     * @return null
     */
    public function __get($key)
    {
        $this->_view->__get($key);
    }

    /**
     * Assign a variable to the view
     *
     * @param string $key The variable name.
     * @param mixed $val The variable value.
     * @return void
     */
    public function __set($key, $val)
    {
        $this->_view->__set($key, $val);
    }

    /**
     * Allows testing with empty() and isset() to work
{'fraction_non_alphanumeric': 0.10806153846153846, 'fraction_numerical': 0.0, 'mean_word_length': 2.0664150943396224, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 41, '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': '2330456', 'n_tokens_mistral': 2277, 'n_tokens_neox': 2274, 'n_words': 627}