<commit_before><?php
// [$QueryPHP] The PHP Framework For Code Poem As Free As Wind. <Query Yet Simple>
// ©2010-2017 http://queryphp.com All rights reserved.
namespace queryyetsimple\event;

<<<queryphp
##########################################################
#   ____                          ______  _   _ ______   #
#  /     \       ___  _ __  _   _ | ___ \| | | || ___ \  #
# |   (  ||(_)| / _ \| '__|| | | || |_/ /| |_| || |_/ /  #
#  \____/ |___||  __/| |   | |_| ||  __/ |  _  ||  __/   #
#       \__   | \___ |_|    \__  || |    | | | || |      #
#     Query Yet Simple      __/  |\_|    |_| |_|\_|      #
#                          |___ /  Since 2010.10.03      #
##########################################################
queryphp;

use RuntimeException;
use queryyetsimple\support\interfaces\container;
use queryyetsimple\event\interfaces\dispatch as interfaces_dispatch;

/**
 * 事件
 *
 * @author <NAME> <<EMAIL>>
 * @package $$
 * @since 2017.04.17
 * @version 1.0
 */
class dispatch implements interfaces_dispatch {
    
    /**
     * 项目容器
     *
     * @var \queryyetsimple\support\interfaces\container
     */
    protected $objContainer;
    
    /**
     * 注册的监听器
     *
     * @var array
     */
    protected $arrListener = [ ];
    
    /**
     * 创建一个事件解析器
     *
     * @param \queryyetsimple\support\interfaces\container $objContainer            
     * @return void
     */
    public function __construct(container $objContainer) {
        $this->objContainer = $objContainer;
    }
    
    /**
     * 执行一个事件
     *
     * @param string|object $mixEvent            
     * @return void
     */
    public function run($mixEvent /* args */ ){
        if (is_object ( $mixEvent )) {
            $objEvent = $mixEvent;
            $mixEvent = get_class ( $mixEvent );
        } else {
            $objEvent = $this->objContainer->make ( $mixEvent );
        }
        
        $arrArgs = func_get_args ();
        array_shift ( $arrArgs );
        array_unshift ( $arrArgs, $objEvent );
        
        if (! $this->hasListener ( $mixEvent )) {
            throw new RuntimeException ( sprintf ( 'Event %s do not have listener', $mixEvent ) );
        }
        
        call_user_func_array ( [ 
                $this->getListener ( $mixEvent ),
                'notify' 
        ], $arrArgs );
    }
    
    /**
     * 注册监听器
     *
     * @param string|array $mixEvent            
     * @param mixed $mixListener            
     * @return void
     */
    public function listener($mixEvent, $mixListener) {
        foreach ( ( array ) $mixEvent as $strEvent ) {
            $this->registerEventSubject ( $strEvent );
            $this->arrListener [$strEvent]->attachs ( $mixListener );
        }
    }
    <commit_msg>event\dispatch remove exception where do not have listener<commit_after><?php
// [$QueryPHP] The PHP Framework For Code Poem As Free As Wind. <Query Yet Simple>
// ©2010-2017 http://queryphp.com All rights reserved.
namespace queryyetsimple\event;

<<<queryphp
##########################################################
#   ____                          ______  _   _ ______   #
#  /     \       ___  _ __  _   _ | ___ \| | | || ___ \  #
# |   (  ||(_)| / _ \| '__|| | | || |_/ /| |_| || |_/ /  #
#  \____/ |___||  __/| |   | |_| ||  __/ |  _  ||  __/   #
#       \__   | \___ |_|    \__  || |    | | | || |      #
#     Query Yet Simple      __/  |\_|    |_| |_|\_|      #
#                          |___ /  Since 2010.10.03      #
##########################################################
queryphp;

use queryyetsimple\support\interfaces\container;
use queryyetsimple\event\interfaces\dispatch as interfaces_dispatch;

/**
 * 事件
 *
 * @author <NAME> <<EMAIL>>
 * @package $$
 * @since 2017.04.17
 * @version 1.0
 */
class dispatch implements interfaces_dispatch {
    
    /**
     * 项目容器
     *
     * @var \queryyetsimple\support\interfaces\container
     */
    protected $objContainer;
    
    /**
     * 注册的监听器
     *
     * @var array
     */
    protected $arrListener = [ ];
    
    /**
     * 创建一个事件解析器
     *
     * @param \queryyetsimple\support\interfaces\container $objContainer            
     * @return void
     */
    public function __construct(container $objContainer) {
        $this->objContainer = $objContainer;
    }
    
    /**
     * 执行一个事件
     *
     * @param string|object $mixEvent            
     * @return void
     */
    public function run($mixEvent /* args */ ){
        if (is_object ( $mixEvent )) {
            $objEvent = $mixEvent;
            $mixEvent = get_class ( $mixEvent );
        } else {
            $objEvent = $this->objContainer->make ( $mixEvent );
        }
        
        $arrArgs = func_get_args ();
        array_shift ( $arrArgs );
        if (is_object ( $objEvent ))
            array_unshift ( $arrArgs, $objEvent );
        
        if (! $this->hasListener ( $mixEvent )) {
            return;
        }
        
        call_user_func_array ( [ 
                $this->getListener ( $mixEvent ),
                'notify' 
        ], $arrArgs );
    }
    
    /**
     * 注册监听器
     *
     * @param string|array $mixEvent            
     * @param mixed $mixListener            
     * @return void
     */
    public function listener($mixEvent, $mixListener) {
        foreach ( ( array ) $mixEvent as $strEvent ) {
            $this->registerEventSubject ( $strEvent );
            $this->arrListener [$strEvent]->attachs ( $mixListener );
        }
    }
    
{'fraction_non_alphanumeric': 0.17738116918594063, 'fraction_numerical': 0.00947004188672373, 'mean_word_length': 1.671206225680934, 'pattern_counts': {'":': 0, '<': 19, '<?xml version=': 0, '>': 27, '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': '2255988', 'n_tokens_mistral': 1772, 'n_tokens_neox': 1716, 'n_words': 284}