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
Conversation
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.
*/ | ||
public function sub(DateInterval $interval): static | ||
{ | ||
$new = clone $this; |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.
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.