src/GameOfLife/OptionHandler/OptionParser.php
/**
     * Parses the board options and returns the Board object or false if an error occurred.
     *
     * @param Getopt $_options The option list
     *
     * @return Board The board
     *
     * @throws \Exception The exception when an invalid border type was specified
     */
Parses the board options and returns the Board object or false if an error occurred.
@param Getopt $_options The option list

@return Board The board

@throws \Exception The exception when an invalid border type was specified
Parses the board options and returns the Board object or false if an error occurred . @param Getopt $_options The option list @return Board The board @throws \ Exception The exception when an invalid border type was specified
public function parseBoardOptions(Getopt $_options)
    {
        if ($_options->getOption("width") !== null) $width = (int)$_options->getOption("width");
        else $width = 20;
        if ($_options->getOption("height") !== null) $height = (int)$_options->getOption("height");
        else $height = 10;
        if ($_options->getOption("maxSteps") !== null) $maxSteps = (int)$_options->getOption("maxSteps");
        else $maxSteps = 50;
        if ($_options->getOption("border") !== null)
        {
            $borderType = $_options->getOption("border");
            if ($borderType == "solid") $hasBorder = true;
            elseif ($borderType == "passthrough") $hasBorder = false;
            else throw new \Exception("Invalid border type specified.");
        }
        else $hasBorder = true;
        return new Board($width, $height, $maxSteps, $hasBorder);
    }
public function parseBoardOptions ( Getopt $ _options ) { if ( $ _options -> getOption ( " width " ) !== null ) $ width = ( int ) $ _options -> getOption ( " width " ) ; else $ width = 20 ; if ( $ _options -> getOption ( " height " ) !== null ) $ height = ( int ) $ _options -> getOption ( " height " ) ; else $ height = 10 ; if ( $ _options -> getOption ( " maxSteps " ) !== null ) $ maxSteps = ( int ) $ _options -> getOption ( " maxSteps " ) ; else $ maxSteps = 50 ; if ( $ _options -> getOption ( " border " ) !== null ) { $ borderType = $ _options -> getOption ( " border " ) ; if ( $ borderType == " solid " ) $ hasBorder = true ; elseif ( $ borderType == " passthrough " ) $ hasBorder = false ; else throw new \ Exception ( " Invalid border type specified. " ) ; } else $ hasBorder = true ; return new Board ( $ width , $ height , $ maxSteps , $ hasBorder ) ; }
Parses the board options and returns the Board object or false if an error occurred.
Parses the board options and returns the Board object or false if an error occurred .
// Fetch board options