<commit_before><?php
/*!
 * Radium
 * Copyright 2011-2014 <NAME>
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

namespace Radium;

/**
 * Event dispatcher.
 *
 * @author <NAME> <<EMAIL>>
 */
class EventDispatcher
{
    /**
     * @var arary
     */
    protected static $listeners = [];

    /**
     * Add a listener to the action.
     *
     * @param string         $action
     * @param array|callable $callback
     */
    public static function addListener($action, $callback)
    {
        // Make sure it's something callable
        if (!is_callable($callback) && !is_array($callback)) {
            throw new Exception("Invalid callback for [{$action}]");
        }

        if (!isset(static::$listeners[$action])) {
            static::$listeners[$action] = [];
        }

        static::$listeners[$action][] = $callback;
    }

    /**
     * Dispatch the event name and pass the parameters to the callbacks.
     *
     * @param string $action
     * @param array  $parameters
     */
    public static function dispatch($action, array $parameters = [])
    {
        if (isset(static::$listeners[$action])) {
            foreach (static::$listeners[$action] as $callback) {
                call_user_func_array($callback, $parameters);
            }
        }
    }
}<commit_msg>If an event returns something, return out of the dispatcher.<commit_after><?php
/*!
 * Radium
 * Copyright 2011-2014 <NAME>
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

namespace Radium;

/**
 * Event dispatcher.
 *
 * @author <NAME> <<EMAIL>>
 */
class EventDispatcher
{
    /**
     * @var arary
     */
    protected static $listeners = [];

    /**
     * Add a listener to the action.
     *
     * @param string         $action
     * @param array|callable $callback
     */
    public static function addListener($action, $callback)
    {
        // Make sure it's something callable
        if (!is_callable($callback) && !is_array($callback)) {
            throw new Exception("Invalid callback for [{$action}]");
        }

        if (!isset(static::$listeners[$action])) {
            static::$listeners[$action] = [];
        }

        static::$listeners[$action][] = $callback;
    }

    /**
     * Dispatch the event name and pass the parameters to the callbacks.
     *
     * @param string $action
     * @param array  $parameters
     */
    public static function dispatch($action, array $parameters = [])
    {
        if (isset(static::$listeners[$action])) {
            foreach (static::$listeners[$action] as $callback) {
                $response = call_user_func_array($callback, $parameters);

                if ($response !== null) {
                    return $response;
                }
            }
        }
    }
}
{'fraction_non_alphanumeric': 0.11898466419883659, 'fraction_numerical': 0.006345848757271285, 'mean_word_length': 2.4204339963833634, 'pattern_counts': {'":': 0, '<': 13, '<?xml version=': 0, '>': 11, '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': '6852225', 'n_tokens_mistral': 1025, 'n_tokens_neox': 1001, 'n_words': 343}