<commit_before><?php

/* This document is meant to follow PSR-1 and PSR-2 php-fig standards
   http://www.php-fig.org/psr/psr-1/
   http://www.php-fig.org/psr/psr-2/ */

/**
 * A factory to inherit from
 * 
 * This file contains the AbstractFactory class which when instantiated can define an
 * abstract factory that can then be 'baked' into the appropriate namespace (or global
 * namespace) and accessed, once baked, as an abstract factory pattern.
 * 
 * @copyright Copyright 2016 <NAME>
 * @author <NAME> <<EMAIL>>
 * @link http://wunk.me/ The author's URL
 * @link http://wunk.me/programming-projects/phabstractic/ Framework URL
 * @license http://opensource.org/licenses/MIT
 * @package Patterns
 * @subpackage Factory
 * @category DesignPatterns
 * 
 */

/**
 * Falcraft Libraries Pattern Implementations Namespace
 * 
 */
namespace Phabstractic\Patterns
{
    require_once(realpath(__DIR__ . '/../') . '/falcraftLoad.php');
    
    /*
     * Configuration.php - Inherits options ability
     * 
     * Set.php - This uses a set to store stuff
     */
    
    $includes = array(// is configurable
                      '/Features/ConfigurationTrait.php',
                      '/Features/Resource/ConfigurationInterface.php',
                      // stores factorires in static set
                      '/Data/Types/Set.php',
                      // throws these exceptions
                      '/Patterns/Exception/CodeGenerationException.php',
                      '/Patterns/Exception/RangeException.php',
                      '/Patterns/Exception/RuntimeException.php',);
                      
    falcraftLoad($includes, __FILE__);
    
    use Phabstractic\Data\Types;
    use Phabstractic\Features;
    use Phabstractic\Features\Resource as FeaturesResource;
    use Phabstractic\Patterns\Exception as PatternsException;
    
    /**
     * AbstractFactory Class - Creates and Defines OO-defined AbstractFactory Classes/Objects
     * 
     * The AbstractFactory class which when instantiated can define an abstract factory
     * that can then be 'baked' into the appropriate namespace (or global namespace) and
     * accessed, once baked, as an AbstractFactory class of itself.
     * 
     * A static 'registry' makes sure that the programmer doesn't try to instantiate
     * a fully qualified AbstractFactory twice, and throws an error.
     * 
     * CHANGELOG
     * 
     * 1.0  created AbstractFactory - May 27th, 2013
     * 2.0: Integrated into Primus2 - August 30th, 2015
     * 3.0: configuration information is now in one place, the constructor
     *      refactored createAbstractFactory to access object properties
     *      clarified all exceptions as coming from patterns/exception
     *      reformatted for inclusion into phabstractic - July 20th, 2016
     * 
     * @version 3.0
     * 
     */
    class AbstractFactory implements FeaturesResource\ConfigurationInterface {
        use Features\ConfigurationTrait;
        
        /**
         * Keeps track of already defined AbstractFactory classes internally
         * 
         * @var Phabstractic\Data\Types\Set
         */
        private static $factories = null;
        
        /**
         * The name of the factory to be generated
         * 
         * @var string
         */
        private $factoryName = '';
        
        /**
         * Whether the class has defined itself
         * 
         * @var bool
         */
        private $baked = false;
        
        /**
         * The constants, name => value, of the enumeration
         * 
         * @var array
         */
        private $constants = null;
        
        /**
         * The abstract methods (turned into-> makeMethodName)
         * 
         * @var Phabstractic\Data\Types\Set
         */
        private $methods = null;
        
        /**
         * The namespace under which the abstract factory class is to be defined
         * 
         * @var string
         */
        private $namespace = '';
        
        /**
         * Generates the required class code and evaluates it
         * 
         * The function that pieces the generated code together and evaluates it
         * 
         * Options:
         * 
         * @param string $factoryName The name of the generate class
         *                            (is turned into AbstractFactoryNameFactory)
         * @param array $methods The methods to put in the factory (are turned into makeMethodName)
         * @param array $constants The constants to put in the factory (are turned uppercase)
         * @param array $options See above options
         * 
         * @return bool if abstract factory class is generated without errors
         * 
         * @throws Phabstractic\Patterns\Exception\CodeGenerationException
         *              if class couldn't be generated
         * 
         */
        private function createAbstractFactory() {
            // Start with blank code
            $classCode = '';
            
            /* Place namespace identifier at top of 'code', as eval statements
               operate outside of the namespace context of the code executing
               the eval statement */
            if (isset($this->conf->namespace) && $this->conf->namespace) {
                $classCode .= 'namespace ' . $this->conf->namespace . "{\n\n";
            }
            
            /* turns factoryName into Abstract{FactoryName}Factory so,
               Book becomes AbstractBookFactory */
            $classCode .= 'abstract class Abstract' . ucfirst($this->factoryName) .
                          'Factory {' . "\n";
            
            foreach ($this->constants as $identifier => $val) {
                // Any class constants (transformed into uppercase)
                $classCode .= 'const ' . strtoupper($identifier) . " = $val;\n\t";
            }
            
            foreach ($this->methods->iterate() as $method) {
                // make the abstract methods, method is turned into makeMethod<commit_msg>Fixed up documentation to be more current<commit_after><?php

/* This document is meant to follow PSR-1 and PSR-2 php-fig standards
   http://www.php-fig.org/psr/psr-1/
   http://www.php-fig.org/psr/psr-2/ */

/**
 * A factory to inherit from
 * 
 * This file contains the AbstractFactory class which when instantiated can define an
 * abstract factory that can then be 'baked' into the appropriate namespace (or global
 * namespace) and accessed, once baked, as an abstract factory pattern.
 * 
 * @copyright Copyright 2016 <NAME>
 * @author <NAME> <<EMAIL>>
 * @link http://wunk.me/ The author's URL
 * @link http://wunk.me/programming-projects/phabstractic/ Framework URL
 * @license http://opensource.org/licenses/MIT
 * @package Patterns
 * @subpackage Factory
 * @category DesignPatterns
 * 
 */

/**
 * Falcraft Libraries Pattern Implementations Namespace
 * 
 */
namespace Phabstractic\Patterns
{
    require_once(realpath(__DIR__ . '/../') . '/falcraftLoad.php');
    
    /*
     * Configuration.php - Inherits options ability
     * 
     * Set.php - This uses a set to store stuff
     */
    
    $includes = array(// is configurable
                      '/Features/ConfigurationTrait.php',
                      '/Features/Resource/ConfigurationInterface.php',
                      // stores factorires in static set
                      '/Data/Types/Set.php',
                      // throws these exceptions
                      '/Patterns/Exception/CodeGenerationException.php',
                      '/Patterns/Exception/RangeException.php',
                      '/Patterns/Exception/RuntimeException.php',);
                      
    falcraftLoad($includes, __FILE__);
    
    use Phabstractic\Data\Types;
    use Phabstractic\Features;
    use Phabstractic\Features\Resource as FeaturesResource;
    use Phabstractic\Patterns\Exception as PatternsException;
    
    /**
     * AbstractFactory Class - Creates and Defines OO-defined AbstractFactory Classes/Objects
     * 
     * The AbstractFactory class which when instantiated can define an abstract factory
     * that can then be 'baked' into the appropriate namespace (or global namespace) and
     * accessed, once baked, as an AbstractFactory class of itself.
     * 
     * A static 'registry' makes sure that the programmer doesn't try to instantiate
     * a fully qualified AbstractFactory twice, and throws an error.
     * 
     * CHANGELOG
     * 
     * 1.0  created AbstractFactory - May 27th, 2013
     * 2.0: Integrated into Primus2 - August 30th, 2015
     * 3.0: configuration information is now in one place, the constructor
     *      refactored createAbstractFactory to access object properties
     *      clarified all exceptions as coming from patterns/exception
     *      reformatted for inclusion into phabstractic - July 20th, 2016
     * 
     * @version 3.0
     * 
     */
    class AbstractFactory implements FeaturesResource\ConfigurationInterface {
        use Features\ConfigurationTrait;
        
        /**
         * Keeps track of already defined AbstractFactory classes internally
         * 
         * @var Phabstractic\Data\Types\Set
         */
        private static $factories = null;
        
        /**
         * The name of the factory to be generated
         * 
         * @var string
         */
        private $factoryName = '';
        
        /**
         * Whether the class has defined itself
         * 
         * @var bool
         */
        private $baked = false;
        
        /**
         * The constants, name => value, of the enumeration
         * 
         * @var array
         */
        private $constants = null;
        
        /**
         * The abstract methods (turned into-> makeMethodName)
         * 
         * @var Phabstractic\Data\Types\Set
         */
        private $methods = null;
        
        /**
         * The namespace under which the abstract factory class is to be defined
         * 
         * @var string
         */
        private $namespace = '';
        
        /**
         * Generates the required class code and evaluates it
         * 
         * The function that pieces the generated code together and evaluates it
         * 
         * Evaluations: $this->factoryName
         *                  The name of the generate class
         *                  (is turned into AbstractFactoryNameFactory)
         *              $this->methods
         *                  The methods to put in the factory
         *                  (are turned into makeMethodName)
         *              $this->constants
         *                  The constants to put in the factory
         *                  (are turned uppercase)
         * 
         * @return bool if abstract factory class is generated without errors
         * 
         * @throws Phabstractic\Patterns\Exception\CodeGenerationException
         *              if class couldn't be generated
         * 
         */
        private function createAbstractFactory() {
            // Start with blank code
            $classCode = '';
            
            /* Place namespace identifier at top of 'code', as eval statements
               operate outside of the namespace context of the code executing
               the eval statement */
            if (isset($this->conf->namespace) && $this->conf->namespace) {
                $classCode .= 'namespace ' . $this->conf->namespace . "{\n\n";
            }
            
            /* turns factoryName into Abstract{FactoryName}Factory so,
               Book becomes AbstractBookFactory */
            $classCode .= 'abstract class Abstract' . ucfirst($this->factoryName) .
                          'Factory {' . "\n";
            
            foreach ($this->constants as $identifier => $val) {
                // Any class constants (transformed into uppercase)
                $classCode .= 'const ' . strtoupper($identifier) . " = $val;\n\t";
            }
            
            foreach ($this->methods->iterate() as $method) {
                // make the abstract methods, method is turned into makeMethod
{'fraction_non_alphanumeric': 0.08555226824457594, 'fraction_numerical': 0.005752794214332676, 'mean_word_length': 1.7309245960502693, 'pattern_counts': {'":': 0, '<': 13, '<?xml version=': 0, '>': 40, 'https://': 0, 'lorem ipsum': 0, 'www.': 4, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 2, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3945502', 'n_tokens_mistral': 3042, 'n_tokens_neox': 2882, 'n_words': 965}