src/GameOfLife/Inputs/BoardEditor/OptionHandler/BoardEditorOptionParser.php
/**
     * Checks whether the argument can be omitted.
     *
     * @param String $_argumentType The type of the argument
     * @param String[] $_arguments The list of already read arguments
     *
     * @return Bool True: The argument can be omitted
     *              False: The argument can not be omitted
     */
Checks whether the argument can be omitted.
@param String $_argumentType The type of the argument
@param String[] $_arguments The list of already read arguments

@return Bool True: The argument can be omitted
False: The argument can not be omitted
Checks whether the argument can be omitted . @param String $_argumentType The type of the argument @param String [] $_arguments The list of already read arguments @return Bool True : The argument can be omitted False : The argument can not be omitted
private function canArgumentBeOmitted(String $_argumentType, array $_arguments): Bool
    {
        $argumentTypeParts = explode("|", $_argumentType);
        array_shift($argumentTypeParts);
        $conditions = $argumentTypeParts;
        foreach ($conditions as $condition)
        {
            $conditionParts = explode("=", $condition);
            $conditionArgumentId = (int)$conditionParts[0];
            $conditionArgumentParts = explode(",", $conditionParts[1]);
            $conditionArgumentType = $conditionArgumentParts[0];
            $conditionArgumentValue = $conditionArgumentParts[1];
            settype($conditionArgumentValue, $conditionArgumentType);
            if ($_arguments[$conditionArgumentId] === $conditionArgumentValue) return true;
        }
        return false;
    }
private function canArgumentBeOmitted ( String $ _argumentType , array $ _arguments ) : Bool { $ argumentTypeParts = explode ( " | " , $ _argumentType ) ; array_shift ( $ argumentTypeParts ) ; $ conditions = $ argumentTypeParts ; foreach ( $ conditions as $ condition ) { $ conditionParts = explode ( " = " , $ condition ) ; $ conditionArgumentId = ( int ) $ conditionParts [ 0 ] ; $ conditionArgumentParts = explode ( " , " , $ conditionParts [ 1 ] ) ; $ conditionArgumentType = $ conditionArgumentParts [ 0 ] ; $ conditionArgumentValue = $ conditionArgumentParts [ 1 ] ; settype ( $ conditionArgumentValue , $ conditionArgumentType ) ; if ( $ _arguments [ $ conditionArgumentId ] === $ conditionArgumentValue ) return true ; } return false ; }
Checks whether the argument can be omitted.
Checks whether the argument can be omitted .
// Split string into option parts // Remove the argument type from the argument type parts