Closed odan closed 8 months ago
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 ChronosClock
because it returns a Chronos instance, that is also a TimeTimeImmutable instance.
Other class names: Clock
, ClockFactory
or DateTimeImmutableFactory
.
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.
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?
Error: Type DateTimeImmutable is not used in this file.
phpcs complains about this problem even though Chronos is inherited from DateTimeImmutable.
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?
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.
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.