Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Replace elseifs with early returns in Connection #153

Merged
merged 1 commit into from
May 23, 2024

Conversation

jeromegamez
Copy link
Contributor

@jeromegamez jeromegamez commented May 23, 2024

This PR proposes replacing all elseif branches in the generated Connection class with early returns.

This is in preparation for #152, which has the primary goal of removing a duplicate check

bunny/src/Connection.php

Lines 342 to 347 in 873ec47

if ($frame instanceof Protocol\MethodConnectionCloseFrame) {
return true;
} elseif ($frame instanceof Protocol\MethodConnectionCloseFrame) {
$this->connectionCloseOk();
throw new ClientException($frame->replyText, $frame->replyCode);
}

The problem there is that this requires removing an if branch and converting an elseif branch to an if branch.

Removing elseif branches in the first place will make this a lot easier.

:octocat:

@WyriHaximus WyriHaximus added this to the v0.6.0 milestone May 23, 2024
Copy link
Collaborator

@WyriHaximus WyriHaximus left a comment

Choose a reason for hiding this comment

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

Great work, thank you for putting this together 👍

@WyriHaximus WyriHaximus merged commit 6aeaaec into jakubkulhan:0.6.x May 23, 2024
56 checks passed
@jeromegamez jeromegamez deleted the early-returns branch May 23, 2024 21:44
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.

None yet

2 participants