src/GameOfLife/Rules/CustomRule.php
/**
     * Checks and returns whether a string is a <stayAlive>G<stayAlive/birth> string.
     *
     * @param String $_rulesString The rules string
     *
     * @return Bool True: The string is a <stayAlive>G<stayAlive/birth> string
     *              False: The string is not a <stayAlive>G<stayAlive/birth> string
     *
     * @throws \Exception The exception when the rule string is in an invalid format
     */
Checks and returns whether a string is a G string.
@param String $_rulesString The rules string

@return Bool True: The string is a G string
False: The string is not a G string

@throws \Exception The exception when the rule string is in an invalid format
Checks and returns whether a string is a G string . @param String $_rulesString The rules string @return Bool True : The string is a G string False : The string is not a G string @throws \ Exception The exception when the rule string is in an invalid format
private function isAlternateNotationString(String $_rulesString): Bool
    {
        if (strstr($_rulesString, "G"))
        {
            $ruleParts = explode("G", $_rulesString);
            if (count($ruleParts) < 2)
            {
                throw new \Exception("The custom rule must have at least 1 birth condition and 1 stay alive condition.");
            }
            elseif (count($ruleParts) > 2)
            {
                throw new \Exception ("The custom rule parts may not contain more than two number strings.");
            }
            else
            {
                if ((is_numeric($ruleParts[0]) || $ruleParts[0] == "") && is_numeric($ruleParts[1])) return true;
                else throw new \Exception("The custom rule parts may only contain \"G\" and numbers.");
            }
        }
        return false;
    }
private function isAlternateNotationString ( String $ _rulesString ) : Bool { if ( strstr ( $ _rulesString , " G " ) ) { $ ruleParts = explode ( " G " , $ _rulesString ) ; if ( count ( $ ruleParts ) < 2 ) { throw new \ Exception ( " The custom rule must have at least 1 birth condition and 1 stay alive condition. " ) ; } elseif ( count ( $ ruleParts ) > 2 ) { throw new \ Exception ( " The custom rule parts may not contain more than two number strings. " ) ; } else { if ( ( is_numeric ( $ ruleParts [ 0 ] ) || $ ruleParts [ 0 ] == " " ) && is_numeric ( $ ruleParts [ 1 ] ) ) return true ; else throw new \ Exception ( " The custom rule parts may only contain  \" G \"  and numbers. " ) ; } } return false ; }
Checks and returns whether a string is a <stayAlive>G<stayAlive/birth> string.
Checks and returns whether a string is a <stayAlive > G<stayAlive / birth > string .