<commit_before><?php

/**
 * Mol_Form_Factory
 *
 * @category PHP
 * @package Mol_Form
 * @author <NAME> <<EMAIL>>
 * @copyright 2012 <NAME>
 * @license http://www.opensource.org/licenses/BSD-3-Clause BSD License
 * @link https://github.com/Matthimatiker/MolComponents
 * @since 01.10.2012
 */

/**
 * Factory that creates form instances.
 *
 * == Usage ==
 *
 * === Creation ===
 *
 * The form factory does not require any constructor arguments.
 * Therefore, the following line is enough to create a new factory:
 * <code>
 * $factory = new Mol_Form_Factory();
 * </code>
 *
 * === Creating forms ===
 *
 * Without further configuration the factory is able to create forms
 * by class name:
 * <code>
 * // Creates a new Zend_Form instance.
 * $form = factory->create('Zend_Form');
 * </code>
 *
 * Each call to create() instantiates a new form, created instances
 * are not cached.
 *
 * === Aliases ===
 *
 * The method addAlias() can be used to register a form alias.
 *
 * Aliases point to form class names and can be passed to
 * create() instead of the full class name:
 * <code>
 * $factory->addAlias('login', 'My_Login_Form');
 * // Creates an instance of My_Login_Form.
 * $form = $factory->create('login');
 * </code>
 *
 * Names of form classes can also be used as alias.
 * That allows mostly transparently switching of form types by
 * configuration:
 * <code>
 * // Creates an instance of My_Login_Form.
 * $form = $factory->create('My_Login_Form');
 * $factory->addAlias('My_Login_Form', 'Another_Login_Form');
 * // Creates an instance of Another_Login_Form.
 * $form = $factory->create('My_Login_Form');
 * </code>
 *
 * === Plugins ===
 *
 * === Enhancing form instances ===
 *
 * @category PHP
 * @package Mol_Form
 * @author <NAME> <<EMAIL>>
 * @copyright 2012 <NAME>
 * @license http://www.opensource.org/licenses/BSD-3-Clause BSD License
 * @link https://github.com/Matthimatiker/MolComponents
 * @since 01.10.2012
 */
class Mol_Form_Factory
{
    
    /**
     * Map from registered aliases to form classes.
     *
     * @var array(string=>string)
     */
    protected $aliases = array();
    
    /**
     * List of registered plugins.
     *
     * @var Mol_Form_Factory_Plugin
     */
    protected $plugins = array();
    <commit_msg>documented usage of form factory plugins<commit_after><?php

/**
 * Mol_Form_Factory
 *
 * @category PHP
 * @package Mol_Form
 * @author <NAME> <<EMAIL>>
 * @copyright 2012 <NAME>
 * @license http://www.opensource.org/licenses/BSD-3-Clause BSD License
 * @link https://github.com/Matthimatiker/MolComponents
 * @since 01.10.2012
 */

/**
 * Factory that creates form instances.
 *
 * == Usage ==
 *
 * === Creation ===
 *
 * The form factory does not require any constructor arguments.
 * Therefore, the following line is enough to create a new factory:
 * <code>
 * $factory = new Mol_Form_Factory();
 * </code>
 *
 * === Creating forms ===
 *
 * Without further configuration the factory is able to create forms
 * by class name:
 * <code>
 * // Creates a new Zend_Form instance.
 * $form = factory->create('Zend_Form');
 * </code>
 *
 * Each call to create() instantiates a new form, created instances
 * are not cached.
 *
 * === Aliases ===
 *
 * The method addAlias() can be used to register a form alias.
 *
 * Aliases point to form class names and can be passed to
 * create() instead of the full class name:
 * <code>
 * $factory->addAlias('login', 'My_Login_Form');
 * // Creates an instance of My_Login_Form.
 * $form = $factory->create('login');
 * </code>
 *
 * Names of form classes can also be used as alias.
 * That allows mostly transparently switching of form types by
 * configuration:
 * <code>
 * // Creates an instance of My_Login_Form.
 * $form = $factory->create('My_Login_Form');
 * $factory->addAlias('My_Login_Form', 'Another_Login_Form');
 * // Creates an instance of Another_Login_Form.
 * $form = $factory->create('My_Login_Form');
 * </code>
 *
 * === Plugins ===
 *
 * Plugins are used to improve just created forms.
 *
 * Any number of plugins can be added to the factory.
 * Instantiated forms are passed to each plugin.
 *
 * The method registerPlugin() is used to add a plugin
 * to the factory:
 * <code>
 * $factory->registerPlugin($myPluginInstance);
 * </code>
 *
 * Plugins must implement the Mol_Form_Factory_Plugin
 * interface.
 *
 * Plugins are applied in registration order.
 *
 * If an already existing form shall be enhanced by
 * plugins, then the form instance can be passed to
 * create():
 * <code>
 * $form = new Zend_Form();
 * $form = $factory->create($form);
 * </code>
 *
 * @category PHP
 * @package Mol_Form
 * @author <NAME> <<EMAIL>>
 * @copyright 2012 <NAME>
 * @license http://www.opensource.org/licenses/BSD-3-Clause BSD License
 * @link https://github.com/Matthimatiker/MolComponents
 * @since 01.10.2012
 */
class Mol_Form_Factory
{
    
    /**
     * Map from registered aliases to form classes.
     *
     * @var array(string=>string)
     */
    protected $aliases = array();
    
    /**
     * List of registered plugins.
     *
     * @var Mol_Form_Factory_Plugin
     */
    protected $plugins = array();
    
{'fraction_non_alphanumeric': 0.13963876480870072, 'fraction_numerical': 0.010099048358904641, 'mean_word_length': 3.342327150084317, 'pattern_counts': {'":': 0, '<': 41, '<?xml version=': 0, '>': 55, 'https://': 4, 'lorem ipsum': 0, 'www.': 4, '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': '7215204', 'n_tokens_mistral': 1602, 'n_tokens_neox': 1551, 'n_words': 506}