aboutsummaryrefslogtreecommitdiffstats
path: root/vendor/mmccook/php-json-canonicalization-scheme/src/Utils.php
diff options
context:
space:
mode:
authorMario <mario@mariovavti.com>2024-03-14 11:15:20 +0000
committerMario <mario@mariovavti.com>2024-03-14 11:15:20 +0000
commit70dfce356b949dce00dba534536be994b1d7761d (patch)
treef398624848854cbbd5ef738bec79f1ed2c28635a /vendor/mmccook/php-json-canonicalization-scheme/src/Utils.php
parent10fbfa06e9eb51485fecbf81d590cd15b7a5a2c2 (diff)
downloadvolse-hubzilla-70dfce356b949dce00dba534536be994b1d7761d.tar.gz
volse-hubzilla-70dfce356b949dce00dba534536be994b1d7761d.tar.bz2
volse-hubzilla-70dfce356b949dce00dba534536be994b1d7761d.zip
next try to use the streams php-jcs library until the floats issue will be fixed upstream. see here for reference https://codeberg.org/streams/streams/issues/151
Diffstat (limited to 'vendor/mmccook/php-json-canonicalization-scheme/src/Utils.php')
-rw-r--r--vendor/mmccook/php-json-canonicalization-scheme/src/Utils.php52
1 files changed, 0 insertions, 52 deletions
diff --git a/vendor/mmccook/php-json-canonicalization-scheme/src/Utils.php b/vendor/mmccook/php-json-canonicalization-scheme/src/Utils.php
deleted file mode 100644
index 57079df3b..000000000
--- a/vendor/mmccook/php-json-canonicalization-scheme/src/Utils.php
+++ /dev/null
@@ -1,52 +0,0 @@
-<?php
-
-namespace Mmccook\JsonCanonicalizator;
-
-class Utils
-{
- /**
- * @param array $array
- * @return bool
- */
- public static function isAssoc(array $array): bool
- {
- $keys = array_keys($array);
-
- return array_keys($keys) !== $keys;
- }
-
- public static function asHex(string $data): string
- {
- return rtrim(chunk_split(bin2hex($data), 2, ' '));
- }
-
- public static function es6NumberFormat(float $number): string
- {
-
- if (is_nan($number) || is_infinite($number)) {
- throw new \RuntimeException("can't use Nan or Infinity in json");
- }
-
- if (0.0 === $number) {
- return '0';
- }
-
- $sign = '';
- if ($number < 0) {
- $sign = '-';
- $number = -$number;
- }
-
- if ($number < 1e+21 && $number >= 1e-6) {
- $formatted = number_format($number, 7, '.', '');
- $formatted = rtrim($formatted, '.0');
- } else {
- $formatted = sprintf('%e', $number);
- $parts = explode('e', $formatted);
- $parts[0] = rtrim($parts[0], '.0');
- $formatted = implode('e', $parts);
- }
-
- return $sign . $formatted;
- }
-}