MCPcopy Create free account
hub / github.com/Rello/analytics / decimalParts

Method decimalParts

lib/Service/FlexibleStorageService.php:1059–1067  ·  view source on GitHub ↗

@return array{int,string,int} */

(string $value)

Source from the content-addressed store, hash-verified

1057
1058 /** @return array{int,string,int} */
1059 private function decimalParts(string $value): array {
1060 $value = trim($value);
1061 if (preg_match('/^([+-]?)([0-9]+)(?:\.([0-9]+))?$/D', $value, $match) !== 1) {
1062 throw new FlexibleStorageException('invalid_numeric_result', 'A database aggregate returned a non-decimal value.', ['value' => $value], 500);
1063 }
1064 $digits = ltrim($match[2] . ($match[3] ?? ''), '0') ?: '0';
1065 $sign = ($match[1] ?? '') === '-' && $digits !== '0' ? -1 : 1;
1066 return [$sign, $digits, strlen($match[3] ?? '')];
1067 }
1068
1069 private function unsignedCompare(string $left, string $right): int {
1070 $left = ltrim($left, '0') ?: '0';

Callers 3

decimalAddMethod · 0.95
decimalCompareMethod · 0.95
decimalDivideMethod · 0.95

Calls

no outgoing calls

Tested by

no test coverage detected