<commit_before><?php

	/**
	 * The TBG event class
	 *
	 * @author <NAME> <<EMAIL>>
	 * @version 2.0
	 * @license http://www.opensource.org/licenses/mozilla1.1.php Mozilla Public License 1.1 (MPL 1.1)
	 * @package thebuggenie
	 * @subpackage core
	 */

	/**
	 * The TBG event class
	 *
	 * @package thebuggenie
	 * @subpackage core
	 */
	final class TBGEvent
	{

		/**
		 * List of registered event listeners
		 *
		 * @var array
		 */
		static protected $_registeredlisteners = array();

		protected $_module = null;

		protected $_identifier = null;

		protected $_return_value = null;

		protected $_subject = null;

		protected $_processed = false;

		protected $_return_list = null;

		protected $_parameters = array();

		/**
		 * Register a listener for a spesified trigger
		 *
		 * @param string $module The module for which the trigger is active
		 * @param string $identifier The trigger identifier
		 * @param string $callback_function Which function to call
		 */
		public static function listen($module, $identifier, $callback_function)
		{
			self::$_registeredlisteners[$module][$identifier][] = $callback_function;
		}

		/**
		 * Whether or not there are any listeners to a specific trigger
		 *
		 * @param string $module The module for which the trigger is active
		 * @param string $identifier The trigger identifier
		 *
		 * @return boolean
		 */
		public static function isAnyoneListening($module, $identifier)
		{
			if (isset(self::$_registeredlisteners[$module]) && isset(self::$_registeredlisteners[$module][$identifier]))
			{
				return true;
			}
			else
			{
				return false;
			}
		}

		/**
		 * Invoke a trigger
		 *
		 * @param string $module The module for which the trigger is active
		 * @param string $identifier The trigger identifier
		 * @param array $params Parameters to pass to the registered listeners
		 *
		 * @return unknown_type
		 */
		protected static function _trigger(TBGEvent $event, $return_when_processed = false)
		{
			$module = $event->getModule();
			$identifier = $event->getIdentifier();
			
			TBGLogging::log("Triggering $module - $identifier");
			if (isset(self::$_registeredlisteners[$module][$identifier]))
			{
				foreach (self::$_registeredlisteners[$module][$identifier] as $trigger)
				{
					try
					{
						if (is_array($trigger))
						{
							TBGLogging::log('Running callback function '.get_class($trigger[0]).'::'.$trigger[1]);
						}
						else
						{
							TBGLogging::log('Running callback function '.$trigger);
						}
						$retval = call_user_func($trigger, $event);
						if ($return_when_processed && $event->isProcessed())
						{
							return true;
						}
						TBGLogging::log('done (Running callback function '.$trigger.')');
					}
					catch (Exception $e)
					{
						throw $e;
					}
				}
			}
			TBGLogging::log("done (Triggering $module - $identifier)");
		}

		/**
		 * Create a new event and return it
		 *
		 * @param string $module
		 * @param string $identifier
		 * @param string $subject
		 *
		 * @return TBGEvent
		 */
		public static function createNew($module, $identifier, $subject = null, $parameters = array())
		{
			$event = new TBGEvent($module, $identifier, $subject, $parameters);
			return $event;
		}

		/**
		 * Create a new event
		 *
		 * @param string $module
		 * @param string $identifier
		 * @param string $subject
		 */
		public function __construct($module, $identifier, $subject = null, $parameters = array(), $initial_list = array())
		{
			$this->_module = $module;
			$this->_identifier = $identifier;
			$this->_subject = $subject;
			$this->_parameters = $parameters;
			$this->_return_list = $initial_list;

			return $this;
		}

		/**
		 * Return the event module
		 *
		 * @return string
		 */
		public function getModule()
		{
			return $this->_module;<commit_msg>forgot to include "initial_list" in createNew function<commit_after><?php

	/**
	 * The TBG event class
	 *
	 * @author <NAME> <<EMAIL>>
	 * @version 2.0
	 * @license http://www.opensource.org/licenses/mozilla1.1.php Mozilla Public License 1.1 (MPL 1.1)
	 * @package thebuggenie
	 * @subpackage core
	 */

	/**
	 * The TBG event class
	 *
	 * @package thebuggenie
	 * @subpackage core
	 */
	final class TBGEvent
	{

		/**
		 * List of registered event listeners
		 *
		 * @var array
		 */
		static protected $_registeredlisteners = array();

		protected $_module = null;

		protected $_identifier = null;

		protected $_return_value = null;

		protected $_subject = null;

		protected $_processed = false;

		protected $_return_list = null;

		protected $_parameters = array();

		/**
		 * Register a listener for a spesified trigger
		 *
		 * @param string $module The module for which the trigger is active
		 * @param string $identifier The trigger identifier
		 * @param string $callback_function Which function to call
		 */
		public static function listen($module, $identifier, $callback_function)
		{
			self::$_registeredlisteners[$module][$identifier][] = $callback_function;
		}

		/**
		 * Whether or not there are any listeners to a specific trigger
		 *
		 * @param string $module The module for which the trigger is active
		 * @param string $identifier The trigger identifier
		 *
		 * @return boolean
		 */
		public static function isAnyoneListening($module, $identifier)
		{
			if (isset(self::$_registeredlisteners[$module]) && isset(self::$_registeredlisteners[$module][$identifier]))
			{
				return true;
			}
			else
			{
				return false;
			}
		}

		/**
		 * Invoke a trigger
		 *
		 * @param string $module The module for which the trigger is active
		 * @param string $identifier The trigger identifier
		 * @param array $params Parameters to pass to the registered listeners
		 *
		 * @return unknown_type
		 */
		protected static function _trigger(TBGEvent $event, $return_when_processed = false)
		{
			$module = $event->getModule();
			$identifier = $event->getIdentifier();
			
			TBGLogging::log("Triggering $module - $identifier");
			if (isset(self::$_registeredlisteners[$module][$identifier]))
			{
				foreach (self::$_registeredlisteners[$module][$identifier] as $trigger)
				{
					try
					{
						if (is_array($trigger))
						{
							TBGLogging::log('Running callback function '.get_class($trigger[0]).'::'.$trigger[1]);
						}
						else
						{
							TBGLogging::log('Running callback function '.$trigger);
						}
						$retval = call_user_func($trigger, $event);
						if ($return_when_processed && $event->isProcessed())
						{
							return true;
						}
						TBGLogging::log('done (Running callback function '.$trigger.')');
					}
					catch (Exception $e)
					{
						throw $e;
					}
				}
			}
			TBGLogging::log("done (Triggering $module - $identifier)");
		}

		/**
		 * Create a new event and return it
		 *
		 * @param string $module
		 * @param string $identifier
		 * @param string $subject
		 *
		 * @return TBGEvent
		 */
		public static function createNew($module, $identifier, $subject = null, $parameters = array(), $initial_list = array())
		{
			$event = new TBGEvent($module, $identifier, $subject, $parameters, $initial_list);
			return $event;
		}

		/**
		 * Create a new event
		 *
		 * @param string $module
		 * @param string $identifier
		 * @param string $subject
		 */
		public function __construct($module, $identifier, $subject = null, $parameters = array(), $initial_list = array())
		{
			$this->_module = $module;
			$this->_identifier = $identifier;
			$this->_subject = $subject;
			$this->_parameters = $parameters;
			$this->_return_list = $initial_list;

			return $this;
		}

		/**
		 * Return the event module
		 *
		 * @return string
		 */
		public function getModule()
		{
			return $this->_module;
{'fraction_non_alphanumeric': 0.12881048125567518, 'fraction_numerical': 0.002594370216629913, 'mean_word_length': 3.0858505564387917, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 27, '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': '6321070', 'n_tokens_mistral': 2829, 'n_tokens_neox': 2175, 'n_words': 636}