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

Method decimalParts

lib/Service/FlexibleStorageService.php:1056–1064  ·  view source on GitHub ↗

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

(string $value)

Source from the content-addressed store, hash-verified

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