|
@@ -29,7 +29,7 @@ discard block |
|
|
block discarded – undo |
|
29
|
29
|
|
|
30
|
30
|
private function stringSplit(string $value): array |
|
31
|
31
|
{ |
|
32
|
|
- return (array)preg_split('//u', $value, -1, PREG_SPLIT_NO_EMPTY); |
|
|
32
|
+ return (array) preg_split('//u', $value, -1, PREG_SPLIT_NO_EMPTY); |
|
33
|
33
|
} |
|
34
|
34
|
|
|
35
|
35
|
public function encode(string $value): string |
|
@@ -40,8 +40,8 @@ discard block |
|
|
block discarded – undo |
|
40
|
40
|
|
|
41
|
41
|
$encoded = ''; |
|
42
|
42
|
do { |
|
43
|
|
- $encoded = $this->dictionary[BC::mod($value, (string)$this->dictionaryLength, 0)] . $encoded; |
|
44
|
|
- $value = BC::div($value, (string)$this->dictionaryLength, 0); |
|
|
43
|
+ $encoded = $this->dictionary[BC::mod($value, (string) $this->dictionaryLength, 0)] . $encoded; |
|
|
44
|
+ $value = BC::div($value, (string) $this->dictionaryLength, 0); |
|
45
|
45
|
} while ($value); |
|
46
|
46
|
|
|
47
|
47
|
return $encoded; |
|
@@ -55,7 +55,7 @@ discard block |
|
|
block discarded – undo |
|
55
|
55
|
if (!isset($charsToPosition[$tmp])) { |
|
56
|
56
|
throw new InvalidArgumentException('cannot decode string with characters not in dictionary'); |
|
57
|
57
|
} |
|
58
|
|
- $out = BC::add($out, BC::mul((string)$charsToPosition[$tmp], BC::pow((string)$this->dictionaryLength, (string)$pos, 0), 0), 0); |
|
|
58
|
+ $out = BC::add($out, BC::mul((string) $charsToPosition[$tmp], BC::pow((string) $this->dictionaryLength, (string) $pos, 0), 0), 0); |
|
59
|
59
|
} |
|
60
|
60
|
|
|
61
|
61
|
return $out; |