You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

43 lines
866 B

3 years ago
  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 [$s, (int) $ns];
  35. }
  36. }