Thanks to visit codestin.com
Credit goes to github.com

Skip to content

[Messenger] Added factory methods to DelayStamp for better DX #38141

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

Merged
merged 1 commit into from
Sep 10, 2020

Conversation

Toflar
Copy link
Contributor

@Toflar Toflar commented Sep 10, 2020

Q A
Branch? master
Bug fix? no
New feature? yes
Deprecations? no
Tickets
License MIT
Doc PR not necessary imho

I often find myself delaying messages for a few minutes or so and I always have to remember the DelayStamp uses milliseconds. I guess these simple factories could improve DX quite a bit :)

@Toflar
Copy link
Contributor Author

Toflar commented Sep 10, 2020

Failing tests unrelated.

@nicolas-grekas nicolas-grekas changed the title Added factory methods to DelayStamp for better DX [Messenger] Added factory methods to DelayStamp for better DX Sep 10, 2020
@nicolas-grekas nicolas-grekas added this to the next milestone Sep 10, 2020

public static function delayForHours(int $hours): self
{
return self::delayForMinutes($hours * 60);
Copy link
Member

Choose a reason for hiding this comment

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

Why not converting hours to milliseconds directly rather than chaining 3 method calls ?

@fabpot
Copy link
Member

fabpot commented Sep 10, 2020

Thank you @Toflar.

1 similar comment
@fabpot
Copy link
Member

fabpot commented Sep 10, 2020

Thank you @Toflar.

@fabpot fabpot merged commit 9cd3e67 into symfony:master Sep 10, 2020
@Toflar Toflar deleted the delaystamp-dx branch September 11, 2020 09:20
@nicolas-grekas nicolas-grekas modified the milestones: next, 5.2 Oct 5, 2020
fabpot added a commit that referenced this pull request Oct 8, 2020
…:delayUntil() (Nyholm)

This PR was squashed before being merged into the 5.x branch.

Discussion
----------

[Messenger] Add DelayStamp::delayFor() and DelayStamp::delayUntil()

| Q             | A
| ------------- | ---
| Branch?       | 5.x
| Bug fix?      | no
| New feature?  | yes
| Deprecations? | no
| Tickets       | Fix #38141
| License       | MIT
| Doc PR        |

This PR will revert the work by @Toflar in #38141. He added some helper methods and I want to add a generic factory method that adds a DateInterval.

This PR will also close #38480 and fix #38459. It is also related to a comment in #36512 (comment) that was liked by a few people.

Maybe adding both `DelayStamp::delayFor(\DateInterval)` and `DelayStamp::delayUntil(\DateTimeInterface)` is overkill. But this covers all the bases and I hope that it will be the last change to this small class.

Commits
-------

c5de1eb [Messenger] Add DelayStamp::delayFor() and DelayStamp::delayUntil()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants