<commit_before><?php
namespace dstuecken\Notify\Handler;

use dstuecken\Notify\Interfaces\NotificationInterface;
use dstuecken\Notify\NotificationCenter;

/**
 * Class SmartyHandler
 *
 * Sends notifications directly to the template system.
 *
 * @author  <NAME> <<EMAIL>>
 * @package idoit\Notify\Handler
 */
class SmartyHandler extends HeaderHandler
{
	/**
	 * @var  \Smarty
	 */
	private $smarty;

	/**
	 * @var  string
	 */
	private $var;

	/**
	 * Handle a notification.
	 *
	 * @param   NotificationInterface  $notification
	 * @param   integer                $level
	 * @return  boolean
	 */
	public function handle(NotificationInterface $notification, $level)
	{
		if (is_a($notification, 'dstuecken\Notify\AttributeAwareInterface'))
		{
			$options = $notification->attributes();
		}
		else
		{
			$options = array();
		}

		if (is_a($notification, 'dstuecken\Notify\TitleAwareInterface'))
		{
			$options['header'] = $notification->title();
		}

		$this->smarty->append($this->var, $notification);

		return true;
	}


	/**
	 * SmartyHandler constructor.
	 *
	 * @param  \Smarty  $template
	 * @param  string   $templateVariable
	 * @param  int      $level
	 * @param  string   $identifier
	 */
	public function __construct (\Smarty $template, $templateVariable = 'notification', $level = NotificationCenter::INFO, $identifier = 'Smarty')
	{
        parent::__construct($identifier, $level);

		$this->smarty = $template;
		$this->var = $templateVariable;
	}
}<commit_msg>assigning notification variable to smarty as array, to be conform with HeaderHandler<commit_after><?php
namespace dstuecken\Notify\Handler;

use dstuecken\Notify\Interfaces\NotificationInterface;
use dstuecken\Notify\NotificationCenter;

/**
 * Class SmartyHandler
 * Sends notifications directly to the template system.
 *
 * @author  <NAME> <<EMAIL>>
 * @package idoit\Notify\Handler
 */
class SmartyHandler extends HeaderHandler
{
	/**
	 * @var  \Smarty
	 */
	private $smarty;

	/**
	 * @var  string
	 */
	private $var;


	/**
	 * Handle a notification.
	 *
	 * @return  boolean
	 */
	public function handle (NotificationInterface $notification, $level)
	{
		if (is_a($notification, 'dstuecken\Notify\AttributeAwareInterface'))
		{
			$options = $notification->attributes();
		}
		else
		{
			$options = array();
		}

		if (is_a($notification, 'dstuecken\Notify\TitleAwareInterface'))
		{
			$options['header'] = $notification->title();
		}

		$variable = [
			'message' => $notification->message(),
			'type' => isset($this->levelMapping[$level]) ? $this->levelMapping[$level] : self::STANDARD,
			'options' => $options
		];

		$current = $this->smarty->getTemplateVars($this->var);

		if (!$current)
		{
			$this->smarty->assign($this->var, [$variable]);
		}
		else
		{
			$this->smarty->append($this->var, $variable);
		}

		return true;
	}


	/**
	 * SmartyHandler constructor.
	 *
	 * @param  \Smarty  $template
	 * @param  string   $templateVariable
	 * @param  integer  $level
	 * @param  string   $identifier
	 */
	public function __construct (\Smarty $template, $templateVariable = 'notification', $level = NotificationCenter::INFO, $identifier = 'Smarty')
	{
		parent::__construct($identifier, $level);

		$this->smarty = $template;
		$this->var = $templateVariable;
	}
}
{'fraction_non_alphanumeric': 0.14972443355786896, 'fraction_numerical': 0.0, 'mean_word_length': 3.727930535455861, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 35, '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': '3195799', 'n_tokens_mistral': 1124, 'n_tokens_neox': 1011, 'n_words': 216}