<commit_before><?php
/**
 * CloudLib :: Lightweight MVC PHP Framework
 *
 * @author      <NAME> <<EMAIL>>
 * @copyright   Copyright (c) 2011 <NAME> <<EMAIL>>
 * @license     MIT License (http://www.opensource.org/licenses/mit-license.php)
 * @package     cloudlib
 */

/**
 * The factory class.
 *
 * <short description>
 *
 * @package     cloudlib
 * @subpackage  cloudlib.lib.classes.core
 * @copyright   Copyright (c) 2011 <NAME> <<EMAIL>>
 * @license     MIT License (http://www.opensource.org/licenses/mit-license.php)
 */
abstract class Factory
{
    /**
     * Constructor
     *
     * @access  public
     * @return  void
     */
    public function __construct() {}

    /**
     * Centralized way of initiating classes
     *
     * @access  public
     * @return  object
     */
    final public static function factory()
    {
        $reflection = new ReflectionClass(get_called_class());
        return $reflection->newInstanceArgs(func_get_args());
    }
}<commit_msg>factory class now stores called objects in an array<commit_after><?php
/**
 * CloudLib :: Lightweight MVC PHP Framework
 *
 * @author      <NAME> <<EMAIL>>
 * @copyright   Copyright (c) 2011 <NAME> <<EMAIL>>
 * @license     MIT License (http://www.opensource.org/licenses/mit-license.php)
 * @package     cloudlib
 */

/**
 * The factory class.
 *
 * <short description>
 *
 * @package     cloudlib
 * @subpackage  cloudlib.lib.classes.core
 * @copyright   Copyright (c) 2011 <NAME> <<EMAIL>>
 * @license     MIT License (http://www.opensource.org/licenses/mit-license.php)
 */
abstract class Factory
{
    /**
     * Array of objects
     *
     * @access  private
     * @var     array
     */
    private static $objects = array();

    /**
     * Constructor
     *
     * @access  public
     * @return  void
     */
    public function __construct() {}

    /**
     * Centralized way of initiating classes
     *
     * @access  public
     * @return  object
     */
    final public static function factory()
    {
        $object = get_called_class();

        if(!in_array($object, self::$objects))
        {
            self::$objects[$object] = new ReflectionClass($object);
            return self::$objects[$object]->newInstanceArgs(func_get_args());
        }

        return self::$objects[$object];
    }
}
{'fraction_non_alphanumeric': 0.13914174252275682, 'fraction_numerical': 0.006935413957520589, 'mean_word_length': 2.429420505200594, 'pattern_counts': {'":': 0, '<': 25, '<?xml version=': 0, '>': 25, 'https://': 0, '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': '2985318', 'n_tokens_mistral': 703, 'n_tokens_neox': 680, 'n_words': 165}