Skip to content

Conversation

@localheinz
Copy link
Contributor

This pull request

  • [x]x extracts a closure to allow using early returns

Related to #664.

}

// SPAM challenge failed
elseif (!test_answer($_POST['func'], $_POST['arga'], $_POST['argb'], $_POST['answer'])) {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This expression here is a bit difficult to refactor in the light of #664:

As @kamil-tekiela pointed out, it makes sense to fail early, and in order to fail early, I would need to add at least one condition here and a try-catch block, to attempt creating a challenge from

  • $_POST['func']
  • $_POST['arga']
  • $_POST['argb']

and if creating a challenge succeeded, compare the expected with the actual answer.

@localheinz localheinz closed this Jul 16, 2022
@localheinz localheinz deleted the fix/return branch July 16, 2022 13:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant