<commit_before><?php

/**
 * Hoa Framework
 *
 *
 * @license
 *
 * GNU General Public License
 *
 * This file is part of HOA Open Accessibility.
 * Copyright (c) 2007, 2008 <NAME>. All rights reserved.
 *
 * HOA Open Accessibility is free software; you can redistribute it and/or
 * modify it under the terms of the GNU General Public License as published by
 * the Free Software Foundation; either version 2 of the License, or
 * (at your option) any later version.
 *
 * HOA Open Accessibility is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with HOA Open Accessibility; if not, write to the Free Software
 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
 *
 *
 * @category    Framework
 * @package     Hoa_Controller
 * @subpackage  Hoa_Controller_Plugin_Standard
 *
 */

/**
 * Hoa_Framework
 */
require_once 'Framework.php';

/**
 * Hoa_Controller_Plugin_Interface
 */
import('Controller.Plugin.Interface');

/**
 * Hoa_Controller_Exception_PluginIsAlreadyRegistered
 */
import('Controller.Exception.PluginIsAlreadyRegistered');

/**
 * Class Hoa_Controller_Plugin_Standard.
 *
 * Manage plugin; it means : register, unregister, and notify them.
 *
 * @author      <NAME> <<EMAIL>>
 * @copyright   Copyright (c) 2007, 2008 <NAME>.
 * @license     http://gnu.org/licenses/gpl.txt GNU GPL
 * @since       PHP 5
 * @version     0.1
 * @package     Hoa_Controller
 * @subpackage  Hoa_Controller_Plugin_Standard
 */

class Hoa_Controller_Plugin_Standard {

    /**
     * Plugins list.
     *
     * @var Hoa_Controller_Plugin_Abstract array
     */
    private $_plugins = array();



    /**
     * Register plugin to notify.
     *
     * @access  public
     * @param   object  $plugin    Hoa_Controller_Plugin_Interface.
     * @return  array
     * @throw   Hoa_Controller_Exception_PluginIsAlreadyRegistered
     * @throw   Hoa_Controller_Exception
     */
    public function register ( Hoa_Controller_Plugin_Interface $plugin ) {

        $pluginIndex = get_class($plugin);

        if(isset($this->_plugins[$pluginIndex]))
            throw new Hoa_Controller_Exception_PluginIsAlreadyRegistered(
                'Plugin %s is already registered.', 0, $pluginIndex);

        $this->_plugins[$pluginIndex] = $plugin;
    }

    /**
     * Unregiser plugin.
     *
     * @access  public
     * @param   string  $pluginIndex    Plugin name.
     * @return  void
     */
    public function unregister ( $pluginIndex = '' ) {

        unset($this->_plugins[$pluginIndex]);
    }

    /**
     * Notify preRouter.
     *
     * @access  public
     * @param   object  $request    Hoa_Controller_Request_Abstract.
     * @return  array
     * @throw   Hoa_Controller_Exception
     */
    public function notifyPreRouter ( Hoa_Controller_Request_Abstract $request ) {

        $return = array();

        foreach($this->_plugins as $index => $plugin)
            $return[$index] = $plugin->preRouter($request);

        return $return;
    }

    /**
     * Notify postRouter.
     *
     * @access  public
     * @param   object  $request    Hoa_Controller_Request_Abstract.
     * @param   object  $router     Hoa_Controller_Router_Standard.
     * @return  array<commit_msg>Correct an API documentation typo and add two empty return instructions.<commit_after><?php

/**
 * Hoa Framework
 *
 *
 * @license
 *
 * GNU General Public License
 *
 * This file is part of HOA Open Accessibility.
 * Copyright (c) 2007, 2008 <NAME>. All rights reserved.
 *
 * HOA Open Accessibility is free software; you can redistribute it and/or
 * modify it under the terms of the GNU General Public License as published by
 * the Free Software Foundation; either version 2 of the License, or
 * (at your option) any later version.
 *
 * HOA Open Accessibility is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with HOA Open Accessibility; if not, write to the Free Software
 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
 *
 *
 * @category    Framework
 * @package     Hoa_Controller
 * @subpackage  Hoa_Controller_Plugin_Standard
 *
 */

/**
 * Hoa_Framework
 */
require_once 'Framework.php';

/**
 * Hoa_Controller_Plugin_Interface
 */
import('Controller.Plugin.Interface');

/**
 * Hoa_Controller_Exception_PluginIsAlreadyRegistered
 */
import('Controller.Exception.PluginIsAlreadyRegistered');

/**
 * Class Hoa_Controller_Plugin_Standard.
 *
 * Manage plugin; it means : register, unregister, and notify them.
 *
 * @author      <NAME> <<EMAIL>>
 * @copyright   Copyright (c) 2007, 2008 <NAME>.
 * @license     http://gnu.org/licenses/gpl.txt GNU GPL
 * @since       PHP 5
 * @version     0.1
 * @package     Hoa_Controller
 * @subpackage  Hoa_Controller_Plugin_Standard
 */

class Hoa_Controller_Plugin_Standard {

    /**
     * Plugins list.
     *
     * @var Hoa_Controller_Plugin_Abstract array
     */
    private $_plugins = array();



    /**
     * Register plugin to notify.
     *
     * @access  public
     * @param   object  $plugin    Hoa_Controller_Plugin_Interface.
     * @return  void
     * @throw   Hoa_Controller_Exception_PluginIsAlreadyRegistered
     * @throw   Hoa_Controller_Exception
     */
    public function register ( Hoa_Controller_Plugin_Interface $plugin ) {

        $pluginIndex = get_class($plugin);

        if(isset($this->_plugins[$pluginIndex]))
            throw new Hoa_Controller_Exception_PluginIsAlreadyRegistered(
                'Plugin %s is already registered.', 0, $pluginIndex);

        $this->_plugins[$pluginIndex] = $plugin;

        return;
    }

    /**
     * Unregiser plugin.
     *
     * @access  public
     * @param   string  $pluginIndex    Plugin name.
     * @return  void
     */
    public function unregister ( $pluginIndex = '' ) {

        unset($this->_plugins[$pluginIndex]);

        return;
    }

    /**
     * Notify preRouter.
     *
     * @access  public
     * @param   object  $request    Hoa_Controller_Request_Abstract.
     * @return  array
     * @throw   Hoa_Controller_Exception
     */
    public function notifyPreRouter ( Hoa_Controller_Request_Abstract $request ) {

        $return = array();

        foreach($this->_plugins as $index => $plugin)
            $return[$index] = $plugin->preRouter($request);

        return $return;
    }

    /**
     * Notify postRouter.
     *
     * @access  public
     * @param   object  $request    Hoa_Controller_Request_Abstract.
     * @param   object  $router     Hoa_Controller_Router_Standard.
     * @return  array
{'fraction_non_alphanumeric': 0.09528543027548991, 'fraction_numerical': 0.009088327179778472, 'mean_word_length': 2.815276273022752, 'pattern_counts': {'":': 0, '<': 15, '<?xml version=': 0, '>': 25, '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': '5094436', 'n_tokens_mistral': 2063, 'n_tokens_neox': 1963, 'n_words': 589}