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

3.x Clean up traits and remove methods from Date #356

Merged
merged 4 commits into from Dec 8, 2022
Merged

Conversation

markstory
Copy link
Member

Inline most of the traits as they only have one usage each. The FormattingTrait was moved up a directory as having a directory with only one file feels a bit silly.

I've also marked several classes as internal because I don't think that userland code should be relying on these classes and logic.

Inline most of the traits as they only have one usage each. The
FormattingTrait was moved up a directory as having a directory with only
one file feels a bit silly.

I've also marked several classes as internal because I don't think that
userland code should be relying on these classes and logic.
src/ChronosDate.php Outdated Show resolved Hide resolved
*/
public function sub(DateInterval $interval): static
{
$new = clone $this;
Copy link
Member

Choose a reason for hiding this comment

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

Should probably assert that hours, minutes second and microseconds aren't set.

Copy link
Member Author

Choose a reason for hiding this comment

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

Isn't resetting the time components enough to prevent the time from being retained? Or are you thinking of throwing an error if the interval includes hours/minutes/seconds/microseconds?

Copy link
Member

@othercorey othercorey Dec 7, 2022

Choose a reason for hiding this comment

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

I was thinking an assert if the interval has those set. The idea is to make users aware of input that isn't kept. However, if you think users will use intervals created from Chronos and not ChronosDate objects, then we can ignore it.

Copy link
Member Author

Choose a reason for hiding this comment

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

👍 Good idea, I've made that change and also updated modify() so that it also disallows modification of time components for consistency.

@othercorey othercorey added this to the 3.x milestone Dec 8, 2022
@othercorey othercorey merged commit b100f7c into 3.x Dec 8, 2022
@othercorey othercorey deleted the trait-cleanup branch December 8, 2022 09:03
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