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

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

@throws \Exception The exception when the rule string is in an invalid format
Checks and returns whether a string is a / string . @param String $_rulesString The rules string @return Bool True : The string is a / string False : The string is not a / string @throws \ Exception The exception when the rule string is in an invalid format
private function isStayAliveSlashBirthString(String $_rulesString): Bool
    {
        if (strstr($_rulesString, "/"))
        {
            $ruleParts = explode("/", $_rulesString);
            foreach ($ruleParts as $index => $rulePart)
            {
                if ($rulePart == "") unset($ruleParts[$index]);
            }
            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)
            {
                if (is_numeric($ruleParts[0]) && is_numeric($ruleParts[1]))
                {
                    return true;
                }
                else throw new \Exception("The custom rule parts may only contain \"/\" and numbers.");
            }
            else throw new \Exception("The custom rule parts may not contain more than two number strings.");
        }
        return false;
    }
private function isStayAliveSlashBirthString ( String $ _rulesString ) : Bool { if ( strstr ( $ _rulesString , " / " ) ) { $ ruleParts = explode ( " / " , $ _rulesString ) ; foreach ( $ ruleParts as $ index => $ rulePart ) { if ( $ rulePart == " " ) unset ( $ ruleParts [ $ index ] ) ; } 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 ) { if ( is_numeric ( $ ruleParts [ 0 ] ) && is_numeric ( $ ruleParts [ 1 ] ) ) { return true ; } else throw new \ Exception ( " The custom rule parts may only contain  \" / \"  and numbers. " ) ; } else throw new \ Exception ( " The custom rule parts may not contain more than two number strings. " ) ; } return false ; }
Checks and returns whether a string is a <stayAlive>/<birth> string.
Checks and returns whether a string is a <stayAlive > / <birth > string .