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

feat(Result): introduce Result::unwrapOr() #470

Merged
merged 5 commits into from
May 4, 2024
Merged

Conversation

simPod
Copy link
Contributor

@simPod simPod commented Apr 19, 2024

I'd like to introduce a function that allows to get inner value from Result if success and allows to bypass throwing an exception from Failure by providing a default value.

@simPod simPod force-pushed the unwrap branch 2 times, most recently from 2d09858 to 922a7ce Compare April 19, 2024 10:09
@coveralls
Copy link

coveralls commented Apr 19, 2024

Pull Request Test Coverage Report for Build 8833515353

Details

  • 2 of 2 (100.0%) changed or added relevant lines in 2 files are covered.
  • No unchanged relevant lines lost coverage.
  • Overall coverage increased (+0.001%) to 98.782%

Totals Coverage Status
Change from base Build 8832169884: 0.001%
Covered Lines: 4379
Relevant Lines: 4433

💛 - Coveralls

src/Psl/Result/unwrapResultOr.php Outdated Show resolved Hide resolved
@simPod simPod force-pushed the unwrap branch 2 times, most recently from 2d4c29e to 73b87bf Compare April 25, 2024 11:38
@simPod simPod changed the title feat(Result): introduce unwrapResultOr() feat(Result): introduce Result::unwrapOr() Apr 25, 2024
@simPod simPod requested a review from veewee April 25, 2024 11:38
@veewee veewee added Priority: Low This issue can probably be picked up by anyone looking to contribute to the project, as an entry fix Status: Review Needed The issue has a PR attached to it which needs to be reviewed. Type: Enhancement Most issues will probably ask for additions or changes. labels Apr 25, 2024
@veewee veewee added this to the 3.0.0 milestone Apr 25, 2024
src/Psl/Result/Failure.php Outdated Show resolved Hide resolved
I'd like to introduce a function that allows to get inner value from Result if success and allows to bypass throwing an exception from Failure by providing a default value.
Copy link
Owner

@azjezz azjezz left a comment

Choose a reason for hiding this comment

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

just a few changes needed :)

src/Psl/Result/Failure.php Outdated Show resolved Hide resolved
src/Psl/Result/ResultInterface.php Outdated Show resolved Hide resolved
src/Psl/Result/Success.php Outdated Show resolved Hide resolved
simPod and others added 4 commits April 25, 2024 15:00
Co-authored-by: Saif Eddin Gmati <29315886+azjezz@users.noreply.github.com>
Co-authored-by: Saif Eddin Gmati <29315886+azjezz@users.noreply.github.com>
Co-authored-by: Saif Eddin Gmati <29315886+azjezz@users.noreply.github.com>
@veewee veewee requested a review from azjezz May 3, 2024 06:28
Copy link
Collaborator

@veewee veewee left a comment

Choose a reason for hiding this comment

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

LGTM

@veewee veewee merged commit a06e6b0 into azjezz:next May 4, 2024
14 checks passed
@simPod simPod deleted the unwrap branch May 5, 2024 09:12
simPod added a commit to simPod/psl that referenced this pull request May 6, 2024
* feat(Result): introduce `Result::unwrapOr()`

I'd like to introduce a function that allows to get inner value from Result if success and allows to bypass throwing an exception from Failure by providing a default value.

* Update src/Psl/Result/Failure.php

Co-authored-by: Saif Eddin Gmati <29315886+azjezz@users.noreply.github.com>

* Update src/Psl/Result/ResultInterface.php

Co-authored-by: Saif Eddin Gmati <29315886+azjezz@users.noreply.github.com>

* Update src/Psl/Result/Success.php

Co-authored-by: Saif Eddin Gmati <29315886+azjezz@users.noreply.github.com>

* style: fix

---------

Co-authored-by: Saif Eddin Gmati <29315886+azjezz@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Priority: Low This issue can probably be picked up by anyone looking to contribute to the project, as an entry fix Status: Review Needed The issue has a PR attached to it which needs to be reviewed. Type: Enhancement Most issues will probably ask for additions or changes.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants