@@ -12,7 +12,7 @@ discard block |
||
| 12 | 12 | * @param string $source Source language |
| 13 | 13 | * @param string $target Target language |
| 14 | 14 | * @param string $text Text to translate |
| 15 | - * @return mixed A token |
|
| 15 | + * @return string A token |
|
| 16 | 16 | */ |
| 17 | 17 | public function generateToken($source, $target, $text) |
| 18 | 18 | { |
@@ -66,7 +66,7 @@ discard block |
||
| 66 | 66 | * Generate "b" parameter |
| 67 | 67 | * The number of hours elapsed, since 1st of January 1970 |
| 68 | 68 | * |
| 69 | - * @return int |
|
| 69 | + * @return double |
|
| 70 | 70 | */ |
| 71 | 71 | private function generateB() |
| 72 | 72 | { |
@@ -82,7 +82,7 @@ discard block |
||
| 82 | 82 | * Process token data by applying multiple operations |
| 83 | 83 | * |
| 84 | 84 | * @param $a |
| 85 | - * @param $b |
|
| 85 | + * @param string $b |
|
| 86 | 86 | * @return int |
| 87 | 87 | */ |
| 88 | 88 | private function RL($a, $b) |
@@ -126,7 +126,7 @@ discard block |
||
| 126 | 126 | * |
| 127 | 127 | * @param string $str |
| 128 | 128 | * @param int $index |
| 129 | - * @return null|number |
|
| 129 | + * @return string |
|
| 130 | 130 | */ |
| 131 | 131 | private function charCodeAt($str, $index) |
| 132 | 132 | { |
@@ -31,13 +31,13 @@ discard block |
||
| 31 | 31 | |
| 32 | 32 | for ($d = array(), $e = 0, $f = 0; $f < mb_strlen($a, 'UTF-8'); $f++) { |
| 33 | 33 | $g = $this->charCodeAt($a, $f); |
| 34 | - if ( 128 > $g ) { |
|
| 34 | + if (128 > $g) { |
|
| 35 | 35 | $d[$e++] = $g; |
| 36 | 36 | } else { |
| 37 | - if ( 2048 > $g ) { |
|
| 37 | + if (2048 > $g) { |
|
| 38 | 38 | $d[$e++] = $g >> 6 | 192; |
| 39 | 39 | } else { |
| 40 | - if ( 55296 == ($g & 64512) && $f + 1 < mb_strlen($a, 'UTF-8') && 56320 == ($this->charCodeAt($a, $f + 1) & 64512) ) { |
|
| 40 | + if (55296 == ($g & 64512) && $f + 1 < mb_strlen($a, 'UTF-8') && 56320 == ($this->charCodeAt($a, $f + 1) & 64512)) { |
|
| 41 | 41 | $g = 65536 + (($g & 1023) << 10) + ($this->charCodeAt($a, ++$f) & 1023); |
| 42 | 42 | $d[$e++] = $g >> 18 | 240; |
| 43 | 43 | $d[$e++] = $g >> 12 & 63 | 128; |
@@ -87,10 +87,10 @@ discard block |
||
| 87 | 87 | */ |
| 88 | 88 | private function RL($a, $b) |
| 89 | 89 | { |
| 90 | - for($c = 0; $c < strlen($b) - 2; $c +=3) { |
|
| 91 | - $d = $b{$c+2}; |
|
| 90 | + for ($c = 0; $c < strlen($b) - 2; $c += 3) { |
|
| 91 | + $d = $b{$c + 2}; |
|
| 92 | 92 | $d = $d >= 'a' ? $this->charCodeAt($d, 0) - 87 : intval($d); |
| 93 | - $d = $b{$c+1} == '+' ? $this->shr32($a, $d) : $a << $d; |
|
| 93 | + $d = $b{$c + 1} == '+' ? $this->shr32($a, $d) : $a << $d; |
|
| 94 | 94 | $a = $b{$c} == '+' ? ($a + $d & 4294967295) : $a ^ $d; |
| 95 | 95 | } |
| 96 | 96 | return $a; |
@@ -105,17 +105,17 @@ discard block |
||
| 105 | 105 | */ |
| 106 | 106 | private function shr32($x, $bits) |
| 107 | 107 | { |
| 108 | - if($bits <= 0) { |
|
| 108 | + if ($bits <= 0) { |
|
| 109 | 109 | return $x; |
| 110 | 110 | } |
| 111 | - if($bits >= 32) { |
|
| 111 | + if ($bits >= 32) { |
|
| 112 | 112 | return 0; |
| 113 | 113 | } |
| 114 | 114 | $bin = decbin($x); |
| 115 | 115 | $l = strlen($bin); |
| 116 | - if($l > 32) { |
|
| 116 | + if ($l > 32) { |
|
| 117 | 117 | $bin = substr($bin, $l - 32, 32); |
| 118 | - } elseif($l < 32) { |
|
| 118 | + } elseif ($l < 32) { |
|
| 119 | 119 | $bin = str_pad($bin, 32, '0', STR_PAD_LEFT); |
| 120 | 120 | } |
| 121 | 121 | return bindec(str_pad(substr($bin, 0, 32 - $bits), 32, '0', STR_PAD_LEFT)); |
@@ -133,7 +133,7 @@ discard block |
||
| 133 | 133 | $char = mb_substr($str, $index, 1, 'UTF-8'); |
| 134 | 134 | if (mb_check_encoding($char, 'UTF-8')) { |
| 135 | 135 | $ret = mb_convert_encoding($char, 'UTF-32BE', 'UTF-8'); |
| 136 | - $result = hexdec(bin2hex($ret)); |
|
| 136 | + $result = hexdec(bin2hex($ret)); |
|
| 137 | 137 | return $result; |
| 138 | 138 | } |
| 139 | 139 | return null; |