Completed
Push — master ( 20dfc8...05ce77 )
by Levan
03:19 queued 01:18
created
src/Stichoza/GoogleTranslate/Tokens/TokenProviderInterface.php 1 patch
Indentation   +9 added lines, -9 removed lines patch added patch discarded remove patch
@@ -7,13 +7,13 @@
 block discarded – undo
7 7
  */
8 8
 interface TokenProviderInterface
9 9
 {
10
-	/**
11
-	 * Generate and return a token
12
-	 * 
13
-	 * @param string $source Source language
14
-	 * @param string $target Target language
15
-	 * @param string $text Text to translate
16
-	 * @return mixed A token
17
-	 */
18
-	public function generateToken($source, $target, $text);
10
+ /**
11
+  * Generate and return a token
12
+  * 
13
+  * @param string $source Source language
14
+  * @param string $target Target language
15
+  * @param string $text Text to translate
16
+  * @return mixed A token
17
+  */
18
+ public function generateToken($source, $target, $text);
19 19
 }
Please login to merge, or discard this patch.
src/Stichoza/GoogleTranslate/Tokens/SampleTokenGenerator.php 1 patch
Indentation   +6 added lines, -6 removed lines patch added patch discarded remove patch
@@ -7,10 +7,10 @@
 block discarded – undo
7 7
  */
8 8
 class SampleTokenGenerator implements TokenProviderInterface
9 9
 {
10
-	/**
11
-	 * Generate a fake token just as an example
12
-	 */
13
-	public function generateToken($source, $target, $text) {
14
-		return sprintf('%d.%d', rand(10000, 99999), rand(10000, 99999));
15
-	}
10
+ /**
11
+  * Generate a fake token just as an example
12
+  */
13
+ public function generateToken($source, $target, $text) {
14
+  return sprintf('%d.%d', rand(10000, 99999), rand(10000, 99999));
15
+ }
16 16
 }
Please login to merge, or discard this patch.
src/Stichoza/GoogleTranslate/Tokens/GoogleTokenGenerator.php 2 patches
Doc Comments   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -12,7 +12,7 @@  discard block
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
     {
Please login to merge, or discard this patch.
Spacing   +8 added lines, -8 removed lines patch added patch discarded remove patch
@@ -37,13 +37,13 @@  discard block
 block discarded – undo
37 37
 
38 38
         for ($d = array(), $e = 0, $f = 0; $f < mb_strlen($a, 'UTF-8'); $f++) {
39 39
             $g = $this->charCodeAt($a, $f);
40
-            if ( 128 > $g ) {
40
+            if (128 > $g) {
41 41
                 $d[$e++] = $g;
42 42
             } else {
43
-                if ( 2048 > $g ) {
43
+                if (2048 > $g) {
44 44
                     $d[$e++] = $g >> 6 | 192;
45 45
                 } else {
46
-                    if ( 55296 == ($g & 64512) && $f + 1 < mb_strlen($a, 'UTF-8') && 56320 == ($this->charCodeAt($a, $f + 1) & 64512) ) {
46
+                    if (55296 == ($g & 64512) && $f + 1 < mb_strlen($a, 'UTF-8') && 56320 == ($this->charCodeAt($a, $f + 1) & 64512)) {
47 47
                         $g = 65536 + (($g & 1023) << 10) + ($this->charCodeAt($a, ++$f) & 1023);
48 48
                         $d[$e++] = $g >> 18 | 240;
49 49
                         $d[$e++] = $g >> 12 & 63 | 128;
@@ -93,10 +93,10 @@  discard block
 block discarded – undo
93 93
      */
94 94
     private function RL($a, $b)
95 95
     {
96
-        for($c = 0; $c < strlen($b) - 2; $c +=3) {
97
-            $d = $b{$c+2};
96
+        for ($c = 0; $c < strlen($b) - 2; $c += 3) {
97
+            $d = $b{$c + 2};
98 98
             $d = $d >= 'a' ? $this->charCodeAt($d, 0) - 87 : intval($d);
99
-            $d = $b{$c+1} == '+' ? $this->shr32($a, $d) : $a << $d;
99
+            $d = $b{$c + 1} == '+' ? $this->shr32($a, $d) : $a << $d;
100 100
             $a = $b{$c} == '+' ? ($a + $d & 4294967295) : $a ^ $d;
101 101
         }
102 102
         return $a;
@@ -121,7 +121,7 @@  discard block
 block discarded – undo
121 121
         $l = strlen($bin);
122 122
         if ($l > 32) {
123 123
             $bin = substr($bin, $l - 32, 32);
124
-        } elseif($l < 32) {
124
+        } elseif ($l < 32) {
125 125
             $bin = str_pad($bin, 32, '0', STR_PAD_LEFT);
126 126
         }
127 127
         return bindec(str_pad(substr($bin, 0, 32 - $bits), 32, '0', STR_PAD_LEFT));
@@ -139,7 +139,7 @@  discard block
 block discarded – undo
139 139
         $char = mb_substr($str, $index, 1, 'UTF-8');
140 140
         if (mb_check_encoding($char, 'UTF-8')) {
141 141
             $ret = mb_convert_encoding($char, 'UTF-32BE', 'UTF-8');
142
-            $result =  hexdec(bin2hex($ret));
142
+            $result = hexdec(bin2hex($ret));
143 143
             return $result;
144 144
         }
145 145
         return null;
Please login to merge, or discard this patch.