/** returns an array of errors if unsuccessful or a User if successful */ public static function registerUser($username, $password, $retypedPassword, $email, $retyptedEmail) { $errors = null; $result = self::registerInputIsValid($username, $password, $retypedPassword, $email, $retyptedEmail); if ($result !== true) { return $result; } else { if (!self::usernameIsAvailable($username)) { $errors['usernameTaken'] = true; return $errors; } else { $result = UserRepository::addUser($username, $password, $email); if ($result !== null) { return $result; } else { $errors['databaseError'] = true; return $errors; } } } }