-
Notifications
You must be signed in to change notification settings - Fork 64
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
Provide PSR-20 Clock implementation #443
Conversation
I am away right now but I think the term ChronosClock is misleading and confusing compared to the other classes. Can we expose this some other way? |
The idea was to name it Other class names: |
After thinking about it, I guess my approach doesn't make sense from a Chronos perspective, because if you are already using Chronos, you may not need the ClockInterface at all. |
I think it is another way for us to participate in the community standards within the larger PHP ecosystem. That alone has value I think. |
What if we implemented it with an anonymous class that's returned by a static helper. That would provide easy access to the interface, right? |
phpcs complains about this problem even though Chronos is inherited from DateTimeImmutable.
A static method cannot then be used like an interface, for example when using dependency injection. |
ChronosFactory or ClockFactory should work then. |
There is one last lint error to fix and then we should be able to move forward with this. |
The class needs to be renamed to ClockFactory. |
src/ClockFactory.php
Outdated
* Redistributions of files must retain the above copyright notice. | ||
* | ||
* @copyright Copyright (c) Cake Software Foundation, Inc. (https://cakefoundation.org) | ||
* @copyright Copyright (c) Daniel Opitz |
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.
We don't need separate copyright, just the cakephp one.
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 added this, because it was also added here:
https://github.com/cakephp/chronos/blob/3.x/src/Chronos.php#L11
https://github.com/cakephp/chronos/blob/3.x/src/DifferenceFormatter.php#L11
Maybe we remove the other redundant copyright tags as well?
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.
The very original Chronos was forked from a different project so Mark inherited a copyright for some of the files. It's very close to not applying now, but definitely not new code.
This PR provides a PSR-20 compliant Clock implementation for the Chronos package.
The PSR-20 Clock interface defines a standard way to interact with system time, allowing for better testability and flexibility.