Php73.php 871 B

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. <?php
  2. /*
  3. * This file is part of the Symfony package.
  4. *
  5. * (c) Fabien Potencier <fabien@symfony.com>
  6. *
  7. * For the full copyright and license information, please view the LICENSE
  8. * file that was distributed with this source code.
  9. */
  10. namespace Symfony\Polyfill\Php73;
  11. /**
  12. * @author Gabriel Caruso <carusogabriel34@gmail.com>
  13. * @author Ion Bazan <ion.bazan@gmail.com>
  14. *
  15. * @internal
  16. */
  17. final class Php73
  18. {
  19. public static $startAt = 1533462603;
  20. /**
  21. * @param bool $asNum
  22. *
  23. * @return array|float|int
  24. */
  25. public static function hrtime($asNum = false)
  26. {
  27. $ns = microtime(false);
  28. $s = substr($ns, 11) - self::$startAt;
  29. $ns = 1E9 * (float) $ns;
  30. if ($asNum) {
  31. $ns += $s * 1E9;
  32. return \PHP_INT_SIZE === 4 ? $ns : (int) $ns;
  33. }
  34. return array($s, (int) $ns);
  35. }
  36. }