File tree Expand file tree Collapse file tree 3 files changed +26
-5
lines changed
Expand file tree Collapse file tree 3 files changed +26
-5
lines changed Original file line number Diff line number Diff line change @@ -87,6 +87,21 @@ public function inNanoseconds(): Nanoseconds
8787
8888 abstract protected function toNanoseconds (): float |int ;
8989
90+ public function __clone (): void
91+ {
92+ throw new \LogicException ('Please use from() to clone. ' );
93+ }
94+
95+ public function __wakeup (): void
96+ {
97+ throw new \LogicException ('Please use from() to deserialize ' );
98+ }
99+
100+ public function __sleep (): array
101+ {
102+ throw new \LogicException ('Time cannot be serialized. ' );
103+ }
104+
90105 public function add (AnyTime $ time ): AnyTime
91106 {
92107 if ($ time ->spacetime !== $ this ->spacetime ) {
Load Diff This file was deleted.
Original file line number Diff line number Diff line change 3636 $ secondInMs = Milliseconds::fromValue (1000 );
3737 $ second = Seconds::from ($ secondInMs );
3838 expect ($ second )->toBe (Seconds::fromValue (1 ));
39+ expect ($ second )->toEqual (Seconds::fromValue (1 ));
3940});
4041
4142test ("Date intervals work " , function () {
5051
5152 expect ($ now ->add ($ var ->toDateInterval ()))->toEqual ($ expected );
5253});
54+
55+ it ('cannot be serialized ' , function () {
56+ $ var = Seconds (1 );
57+ expect (fn () => serialize ($ var ))->toThrow (LogicException::class);
58+ });
59+
60+ it ('cannot be cloned ' , function () {
61+ $ var = Seconds (1 );
62+ expect (fn () => clone $ var )->toThrow (LogicException::class);
63+ });
You can’t perform that action at this time.
0 commit comments