You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: proposed/clock-meta.md
+3-3Lines changed: 3 additions & 3 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -14,7 +14,7 @@ There are currently a few libraries that provide this functionality, however the
14
14
15
15
Symfony provides a package called `symfony/phpunit-bridge` that has a `Symfony\Bridge\PhpUnit\ClockMock` class, which allows mocking PHP's built-in time and date functions, however this does not solve mocking calls to `new \DateTimeImmutable()`. It also does not fully mock time when called from other libraries that rely on the system time.
16
16
17
-
`Cake\Chronos\Chronos`does provide mocking via a static `setTestNow()` method, but this has its own pitfalls as it provides no isolation and must be called again to stop mocking.
17
+
`Carbon\Carbon` – and being forked from that also `Cake\Chronos\Chronos`– do provide mocking via a static `setTestNow()` method, but this has its own pitfalls as it provides no isolation and must be called again to stop mocking.
18
18
19
19
Pros:
20
20
@@ -54,7 +54,7 @@ We have decided to formalize the existing practices, used by several other packa
54
54
55
55
(This list is not exhaustive!)
56
56
57
-
interfaces, and some relying on overloading (extending) the Clock class to mock the
57
+
Some of these providing interfaces, and some relying on overloading (extending) the Clock class to mock the
58
58
current time.
59
59
60
60
These implementations all provide a `now()` method which returns a `DateTimeImmutable` object. As the `DateTimeImmutable` object allows retrieving the Unix timestamp, by calling `getTimestamp()` or `format('u.U')`, this interface does not define any special methods to retrieve a Unix timestamp or any other time information that is not available from a `DateTimeImmutable` object.
@@ -65,7 +65,7 @@ Time by now is defined by interaction of electromagnetic radiation with the exci
65
65
66
66
This means that for the sake of this PSR the timezone is considered an implementation detail of the interface.
67
67
68
-
It is up to the implementation to make sure that the timezone is handled according to the business logic of the application. That is either by making sure that a call to `now()` will only return a `DateTimeImmutable` object with a known timezone (implicit contract) or by explicitly changing the timezone to be correct for the application. This an be done by calling `setTimezone()` to create a new `DateTimeImmutable` object with the given timezone.
68
+
It is up to the implementation to make sure that the timezone is handled according to the business logic of the application. That is either by making sure that a call to `now()` will only return a `DateTimeImmutable` object with a known timezone (implicit contract) or by explicitly changing the timezone to be correct for the application. This can be done by calling `setTimezone()` to create a new `DateTimeImmutable` object with the given timezone.
69
69
70
70
These are though actions that are not part of the contract which this interface defines.
0 commit comments