diff --git a/src/Psl/DateTime/Duration.php b/src/Psl/DateTime/Duration.php index 08ef7044..0dad888d 100644 --- a/src/Psl/DateTime/Duration.php +++ b/src/Psl/DateTime/Duration.php @@ -58,8 +58,7 @@ private function __construct( public static function fromParts(int $hours, int $minutes = 0, int $seconds = 0, int $nanoseconds = 0): self { // This is where the normalization happens. - $s = - (SECONDS_PER_HOUR * $hours) + (SECONDS_PER_MINUTE * $minutes) + + $s = (SECONDS_PER_HOUR * $hours) + (SECONDS_PER_MINUTE * $minutes) + $seconds + ((int) ($nanoseconds / NANOSECONDS_PER_SECOND)); $ns = $nanoseconds % NANOSECONDS_PER_SECOND; if ($s < 0 && $ns > 0) { diff --git a/tests/unit/Result/FailureTest.php b/tests/unit/Result/FailureTest.php index 9116dad1..51fef31c 100644 --- a/tests/unit/Result/FailureTest.php +++ b/tests/unit/Result/FailureTest.php @@ -53,7 +53,10 @@ public function testProceed(): void { $exception = new Exception('bar'); $wrapper = new Failure($exception); - $actual = $wrapper->proceed(static fn(string $_result): int => 200, static fn(Exception $_exception): int => 404); + $actual = $wrapper->proceed( + static fn(string $_result): int => 200, + static fn(Exception $_exception): int => 404, + ); static::assertSame(404, $actual); } diff --git a/tests/unit/Result/SuccessTest.php b/tests/unit/Result/SuccessTest.php index a5448630..8860c9b8 100644 --- a/tests/unit/Result/SuccessTest.php +++ b/tests/unit/Result/SuccessTest.php @@ -52,7 +52,10 @@ public function testGetException(): void public function testProceed(): void { $wrapper = new Success('hello'); - $actual = $wrapper->proceed(static fn(string $_result): int => 200, static fn(Exception $_exception): int => 404); + $actual = $wrapper->proceed( + static fn(string $_result): int => 200, + static fn(Exception $_exception): int => 404, + ); static::assertSame(200, $actual); }