-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* develop: specify next release bump minimum version of psalm add periods named constructor use high resolution time to compare the milliseconds elasped between 2 points in time use blackbox 5
- Loading branch information
Showing
32 changed files
with
195 additions
and
52 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,17 +1,22 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" colors="true" bootstrap="vendor/autoload.php" xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/9.3/phpunit.xsd" printerClass="Innmind\BlackBox\PHPUnit\ResultPrinterV9"> | ||
<coverage> | ||
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" colors="true" bootstrap="vendor/autoload.php" xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/10.2/phpunit.xsd"> | ||
<extensions> | ||
<bootstrap class="Innmind\BlackBox\PHPUnit\Extension"> | ||
</bootstrap> | ||
</extensions> | ||
<coverage/> | ||
<testsuites> | ||
<testsuite name="Time continuum test suite"> | ||
<directory>./tests</directory> | ||
</testsuite> | ||
</testsuites> | ||
<source> | ||
<include> | ||
<directory>.</directory> | ||
</include> | ||
<exclude> | ||
<directory>./tests</directory> | ||
<directory>./vendor</directory> | ||
</exclude> | ||
</coverage> | ||
<testsuites> | ||
<testsuite name="Time continuum test suite"> | ||
<directory>./tests</directory> | ||
</testsuite> | ||
</testsuites> | ||
</source> | ||
</phpunit> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
<?php | ||
declare(strict_types = 1); | ||
|
||
namespace Innmind\TimeContinuum\Earth\PointInTime; | ||
|
||
use Innmind\TimeContinuum\Earth\ElapsedPeriod; | ||
|
||
/** | ||
* @psalm-immutable | ||
*/ | ||
final class HighResolution | ||
{ | ||
/** @var 0|positive-int */ | ||
private int $seconds; | ||
/** @var 0|positive-int */ | ||
private int $nanoseconds; | ||
|
||
/** | ||
* @param 0|positive-int $seconds | ||
* @param 0|positive-int $nanoseconds | ||
*/ | ||
private function __construct(int $seconds, int $nanoseconds) | ||
{ | ||
$this->seconds = $seconds; | ||
$this->nanoseconds = $nanoseconds; | ||
} | ||
|
||
public static function now(): self | ||
{ | ||
/** | ||
* @var 0|positive-int $seconds | ||
* @var 0|positive-int $nanoseconds | ||
*/ | ||
[$seconds, $nanoseconds] = \hrtime(); | ||
|
||
return new self($seconds, $nanoseconds); | ||
} | ||
|
||
public function elapsedSince(self $time): ElapsedPeriod | ||
{ | ||
$seconds = $this->seconds - $time->seconds; | ||
$nanoseconds = match ($seconds) { | ||
0 => $this->nanoseconds - $time->nanoseconds, | ||
default => (1_000_000_000 + $this->nanoseconds) - $time->nanoseconds, | ||
}; | ||
|
||
$milliseconds = ($seconds * 1_000) + (int) ($nanoseconds / 1_000_000); | ||
|
||
return ElapsedPeriod::of($milliseconds); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.