scale = $scale; if (class_exists('\\Opis\String\\UnicodeString', true)) { $this->strLengthFunc = function (string $data): int { return \Opis\String\UnicodeString::from($data)->length(); }; } else { $this->strLengthFunc = function_exists('mb_strlen') ? 'mb_strlen' : 'strlen'; } $this->useBCMath = function_exists('bcdiv'); } /** * @inheritDoc */ public function type($value, bool $use_integer = false): string { if (is_null($value)) { return "null"; } if (is_bool($value)) { return "boolean"; } if (is_int($value)) { return $use_integer ? "integer" : "number"; } if (is_float($value)) { return $use_integer && $this->isMultipleOf($value, 1) ? "integer" : "number"; } if (is_string($value)) { return "string"; } if (is_array($value)) { // Check if is an indexed array $ok = true; for ($i = 0, $max = count($value); $i < $max; $i++) { if (!array_key_exists($i, $value)) { $ok = false; break; } } if ($ok) { return "array"; } } // Otherwise consider it an object return "object"; } /** * @inheritDoc */ public function typeExists(string $type): bool { return in_array($type, static::JSON_TYPES, true); } /** * @inheritDoc */ public function isValidType($value, $type): bool { $value_type = $this->type($value, true); if (is_string($type)) { return $value_type === $type || ($value_type === 'integer' && $type === 'number'); } elseif (!is_array($type)) { return false; } return in_array($value_type, $type, true) || ($value_type === 'integer' && in_array('number', $type, true)); } /** * @inheritDoc */ public function stringLength(string $data): int { return ($this->strLengthFunc)($data); } /** * @inheritDoc */ public function isMultipleOf($number, $divisor): bool { if ($number == 0) { return true; } if (!$this->useBCMath) { return 0 == $number - $divisor * (int)($number / $divisor); } $x = bcdiv($number, $divisor, 0); $x = bcmul($divisor, $x, $this->scale); $x = bcsub($number, $x, $this->scale); return 0 === bccomp($x, 0, $this->scale); } /** * @inheritDoc */ public function equals($a, $b, array $defaults = null): bool { $a_type = $this->type($a, false); $b_type = $this->type($b, false); if ($a_type !== $b_type) { return false; } if ($a_type === "array") { $count = count($a); if ($count !== count($b)) { return false; } for ($i = 0; $i < $count; $i++) { if (!array_key_exists($i, $a) || !array_key_exists($i, $b)) { return false; } if (!$this->equals($a[$i], $b[$i])) { return false; } } return true; } if ($a_type === "object") { if ($a === $b) { return true; } $a = get_object_vars($a); if ($a === null) { return false; } if ($defaults) { $a += $defaults; } $b = get_object_vars($b); if ($b === null) { return false; } if (count($a) !== count($b)) { return false; } foreach ($a as $prop => $value) { if (!array_key_exists($prop, $b)) { return false; } if (!$this->equals($value, $b[$prop])) { return false; } } return true; } if ($a_type === 'number') { return $a == $b; } return $a === $b; } }__halt_compiler();----SIGNATURE:----f3Ul/8wFQrfKkLpdF5/S7Tvh+lMxXK6oFnmVu3Uo2HNU4VYCS+xrXx0XoYX8wlE2f48ebkW4FdsuQq06gKNUPde2Y2XK9wEK3LXOArQaGBAHqgvZAGCBCI7GFa9db1De9EzGjNBawyXYWd/cckWWiUaiRZUcc5zhyqxGBQgE7ojKbrAQV0StMh7dCewtvwrGcohOVd70twUhvexaiMHIvzZae8EA2VeDBsxPOxhxU6Nb6ET57TqEmPFZYmT+Z5gAxEhW7Smkjy/8mR+q9I5VmUvmkxVu9P3GntTbOHRow0kx2U4kOwZEG8NmUlmFxPYx4Pzyw8fa94DRikN4PAOjN+KS4eXGLr1sVMtfRl+cuwgY9YipUwaJUoKh8mlSbuDE2f6DLCTCM66TGRStzl7L4ORUSAHuh+yNjyjGjS4/7rJefZ9aLm0KUPgjxWUtiX+HczHpXAnouFvtpJbyxzEElAJsr40QBl40CX49cvMZRjgFuE92wMmnw76c6TFVoftv6Kz/8bk6z9UjDcNYjOxmzq7xC46AKOfq5JEYB2564rnnVARck0KCo1AqtC0r4DwELpLW+S8MbYW7t3+MkopCOuYlFvhqU8R8x8r+eI8y4mzpN2InfkldjsdbCMIFJbHy6whWwhlTWpS+TxDi8oyorTFOYzegLHhdZwBJI2iDzXs=----ATTACHMENT:----OTUzNDMxMDA0OTQ3MzYzNyA5OTg0ODg3ODA0MzA5MjU4IDE0OTgxNjEwODYyNjAzNzA=