<commit_before><?php


namespace Gossamer\Horus\EventListeners;

use Monolog\Logger;
use Gossamer\Horus\Core\Request;

class EventHandler
{
    private $listeners = array();
    
    private $state = null;
    
    private $params = null;
    
    private $logger = null;
   
    private $request = null;
    
    public function __construct(Logger $logger, Request $request) {
        
        $this->logger = $logger;
        $this->request = $request;
        
    }
    
    
    public function addListener($listener) {
        
        $this->listeners[] = $listener;
        $this->logger->addDebug($listener['listener'] . ' added to listeners');
    }


    public function notifyListeners() {
   
        $this->logger->addDebug('notifying listeners');
       
        foreach($this->listeners as $listener) {
            $listenerClass= $listener['listener'];
            $handler = array($listenerClass, 'on_' . $this->state);
        
            if($this->state == $listener['event'] && is_callable($handler)) {
              
                $eventListener = new $listenerClass($this->logger, $this->request);    
                $eventListener->setConfig($listener);
                $eventListener->execute($this->state, $this->params);
            } else {
                $this->logger->addError($listenerClass . ' not found by EventHandler::notifyListeners');             
            }
        }<commit_msg>made request object passed in by reference<commit_after><?php


namespace Gossamer\Horus\EventListeners;

use Monolog\Logger;
use Gossamer\Horus\Core\Request;

class EventHandler
{
    private $listeners = array();
    
    private $state = null;
    
    private $params = null;
    
    private $logger = null;
   
    private $request = null;
    
    public function __construct(Logger $logger, Request &$request) {
        
        $this->logger = $logger;
        $this->request = $request;
        
    }
    
    
    public function addListener($listener) {
        
        $this->listeners[] = $listener;
        $this->logger->addDebug($listener['listener'] . ' added to listeners');
    }


    public function notifyListeners() {
   
        $this->logger->addDebug('notifying listeners');
       
        foreach($this->listeners as $listener) {
            $listenerClass= $listener['listener'];
            $handler = array($listenerClass, 'on_' . $this->state);
        
            if($this->state == $listener['event'] && is_callable($handler)) {
              
                $eventListener = new $listenerClass($this->logger, $this->request);    
                $eventListener->setConfig($listener);
                $eventListener->execute($this->state, $this->params);
            } else {
                $this->logger->addError($listenerClass . ' not found by EventHandler::notifyListeners');             
            }
        }
{'fraction_non_alphanumeric': 0.1321998612074948, 'fraction_numerical': 0.0, 'mean_word_length': 2.0572640509013786, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 39, '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': '6031743', 'n_tokens_mistral': 772, 'n_tokens_neox': 763, 'n_words': 152}