<commit_before><?php
/**
 * Adapter for Smarty
 *
 * @file    SmartyAdapter.php
 *
 * PHP version 5.3.9+
 * Smarty version 3+
 *
 * @author  <NAME> <<EMAIL>>
 * @date    2013-05-18 17:59
 * @copyright The BSD 3-Clause License
 */

namespace Veles\View\Adapters;

use Exception;
use /** @noinspection PhpUndefinedClassInspection */ Smarty;

/**
 * Class SmartyAdapter
 *
 * @author  <NAME> <<EMAIL>>
 */
class SmartyAdapter extends ViewAdapterAbstract implements iViewAdapter
{
	/** @var  null|array */
	protected static $calls;
	/** @var iViewAdapter|$this */
	protected static $instance;
	/**
	 * Constructor
	 */
	final public function __construct()
	{
		/** @noinspection PhpIncludeInspection */
		include 'Smarty' . DIRECTORY_SEPARATOR . 'Smarty.class.php';
		/** @noinspection PhpUndefinedClassInspection */
		$this->setDriver(new Smarty);
	}

	/**
	 * Method for output variables setup
	 *
	 * @param mixed $vars Output variables array or traversable class
	 */
	final public function set($vars)
	{
		foreach ($vars as $name => $value) {
			$this->getDriver()->assign($name, $value);
		}
	}

	/**
	 * Output variables cleanup
	 *
	 * @param array $vars Variables array for cleanup
	 * @throws Exception
	 */
	final public function del($vars)
	{
		if (!is_array($vars)) {
			throw new Exception('View can unset variables only in arrays!');
		}

		foreach ($vars as $name) {
			$this->getDriver()->clearAssign($name);
		}
	}

	/**
	 * Output method
	 *
	 * @param string $path Path to template
	 */
	final public function show($path)
	{
		$this->getDriver()->display($path);
	}

	/**
	 * Return value of View compilation
	 *
	 * @param string $path Path to template
	 * @return string View content
	 */
	final public function get($path)
	{
		return $this->getDriver()->fetch($path);
	}

	/**
	 * Clear template cache
	 *
	 * @param string $tpl
	 * @return mixed
	 */
	final public function clearCache($tpl)
	{
		return $this->getDriver()->clearCache($tpl);
	}

	/**
	 * Clear all template caches
	 *
	 * @param mixed $exp_time
	 * @return mixed
	 */
	final public function clearAllCache($exp_time = null)
	{
		return $this->getDriver()->clearAllCache($exp_time);
	}

	/**
	 * Check is template already cached
	 * @param $tpl
	 * @return bool
	 */
	final public function isCached($tpl)
	{
		return $this->getDriver()->isCached($tpl);
	}
}
<commit_msg>Remove final reserved word from SmartyAdapter<commit_after><?php
/**
 * Adapter for Smarty
 *
 * @file    SmartyAdapter.php
 *
 * PHP version 5.3.9+
 * Smarty version 3+
 *
 * @author  <NAME> <<EMAIL>>
 * @date    2013-05-18 17:59
 * @copyright The BSD 3-Clause License
 */

namespace Veles\View\Adapters;

use Exception;
use /** @noinspection PhpUndefinedClassInspection */ Smarty;

/**
 * Class SmartyAdapter
 *
 * @author  <NAME> <<EMAIL>>
 */
class SmartyAdapter extends ViewAdapterAbstract implements iViewAdapter
{
	/** @var  null|array */
	protected static $calls;
	/** @var iViewAdapter|$this */
	protected static $instance;
	/**
	 * Constructor
	 */
	public function __construct()
	{
		/** @noinspection PhpIncludeInspection */
		include 'Smarty' . DIRECTORY_SEPARATOR . 'Smarty.class.php';
		/** @noinspection PhpUndefinedClassInspection */
		$this->setDriver(new Smarty);
	}

	/**
	 * Method for output variables setup
	 *
	 * @param mixed $vars Output variables array or traversable class
	 */
	public function set($vars)
	{
		foreach ($vars as $name => $value) {
			$this->getDriver()->assign($name, $value);
		}
	}

	/**
	 * Output variables cleanup
	 *
	 * @param array $vars Variables array for cleanup
	 * @throws Exception
	 */
	public function del($vars)
	{
		if (!is_array($vars)) {
			throw new Exception('View can unset variables only in arrays!');
		}

		foreach ($vars as $name) {
			$this->getDriver()->clearAssign($name);
		}
	}

	/**
	 * Output method
	 *
	 * @param string $path Path to template
	 */
	public function show($path)
	{
		$this->getDriver()->display($path);
	}

	/**
	 * Return value of View compilation
	 *
	 * @param string $path Path to template
	 * @return string View content
	 */
	public function get($path)
	{
		return $this->getDriver()->fetch($path);
	}

	/**
	 * Clear template cache
	 *
	 * @param string $tpl
	 * @return mixed
	 */
	public function clearCache($tpl)
	{
		return $this->getDriver()->clearCache($tpl);
	}

	/**
	 * Clear all template caches
	 *
	 * @param mixed $exp_time
	 * @return mixed
	 */
	public function clearAllCache($exp_time = null)
	{
		return $this->getDriver()->clearAllCache($exp_time);
	}

	/**
	 * Check is template already cached
	 * @param $tpl
	 * @return bool
	 */
	public function isCached($tpl)
	{
		return $this->getDriver()->isCached($tpl);
	}
}

{'fraction_non_alphanumeric': 0.1474850809889173, 'fraction_numerical': 0.007246376811594203, 'mean_word_length': 3.394194756554307, 'pattern_counts': {'":': 0, '<': 17, '<?xml version=': 0, '>': 47, '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': '1531855', 'n_tokens_mistral': 1646, 'n_tokens_neox': 1505, 'n_words': 403}