src/GameOfLife/OptionHandler/OptionParser.php
/**
     * Parses the input, output and rule options.
     *
     * @param Getopt $_options The options list
     * @param String $_optionName The option name (input, output or rule)
     * @param String $_classNameSpace The class name space
     * @param String $_classSuffix The class suffix
     *
     * @return BaseInput|BaseOutput|BaseRule|Bool The class instance or false if no class was found from the options
     *
     * @throws \Exception The exceptions of the Input, Output or Rule constructors
     */
Parses the input, output and rule options.
@param Getopt $_options The options list
@param String $_optionName The option name (input, output or rule)
@param String $_classNameSpace The class name space
@param String $_classSuffix The class suffix

@return BaseInput|BaseOutput|BaseRule|Bool The class instance or false if no class was found from the options

@throws \Exception The exceptions of the Input, Output or Rule constructors
Parses the input output and rule options . @param Getopt $_options The options list @param String $_optionName The option name ( input output or rule ) @param String $_classNameSpace The class name space @param String $_classSuffix The class suffix @return BaseInput|BaseOutput|BaseRule|Bool The class instance or false if no class was found from the options @throws \ Exception The exceptions of the Input Output or Rule constructors
private function parseClassOptions(Getopt $_options, String $_optionName, String $_classNameSpace, String $_classSuffix)
    {
        if ($_options->getOption($_optionName) !== null)
        {
            $className = ucfirst(strtolower($_options->getOption($_optionName))) . $_classSuffix;
            $classPath = $_classNameSpace . "\\" . $className;
            if (class_exists($classPath) &&
                ! in_array($className, $this->parentOptionHandler->excludeClasses()))
            {
                return new $classPath;
            }
        }
        foreach ($this->parentOptionHandler->linkedOptions() as $option => $className)
        {
            if (stristr($className, $_classSuffix) && $_options->getOption($option) !== null)
            {
                return new $className;
            }
        }
        return false;
    }
private function parseClassOptions ( Getopt $ _options , String $ _optionName , String $ _classNameSpace , String $ _classSuffix ) { if ( $ _options -> getOption ( $ _optionName ) !== null ) { $ className = ucfirst ( strtolower ( $ _options -> getOption ( $ _optionName ) ) ) . $ _classSuffix ; $ classPath = $ _classNameSpace . " \\ " . $ className ; if ( class_exists ( $ classPath ) && ! in_array ( $ className , $ this -> parentOptionHandler -> excludeClasses ( ) ) ) { return new $ classPath ; } } foreach ( $ this -> parentOptionHandler -> linkedOptions ( ) as $ option => $ className ) { if ( stristr ( $ className , $ _classSuffix ) && $ _options -> getOption ( $ option ) !== null ) { return new $ className ; } } return false ; }
Parses the input, output and rule options.
Parses the input output and rule options .
// check whether any linked option (input/output/rule specific option) is set // if input/output/rule specific option is set return new instance of the class which the input refers to