Completed
Push — master ( 47f639...f56d28 )
by Aitor Riba
12s
created
src/Translation.php 2 patches
Indentation   +69 added lines, -69 removed lines patch added patch discarded remove patch
@@ -130,75 +130,75 @@
 block discarded – undo
130 130
         }
131 131
     }
132 132
 
133
-     /**
134
-      * Get translation from mymemory API.
135
-      */
136
-     public function mymemoryTrans()
137
-     {
138
-         // Check if it can be translated from online sources.
139
-
140
-         $host = 'api.mymemory.translated.net';
141
-         if ($socket = @fsockopen($host, 80, $errno, $errstr, 30)) {
142
-
143
-             // Host online
144
-             $urlString = urlencode($this->string);
145
-             $url = "http://$host/get?q=$urlString&langpair=$this->from%7C$this->to";
146
-             $json = file_get_contents($url);
147
-             $data = json_decode($json);
148
-
149
-             // Checking response status
150
-
151
-             if ($data->responseStatus != 200) {
152
-                 if ($this->debug == true) {
153
-                     $details = $data->responseDetails;
154
-                     if ($data->responseStatus == 403) {
155
-                         $details = ($data->responseDetails);
156
-                     }
157
-                     $this->translation = "<font style='color:red;'>Error ".$data->responseStatus.': '.$details.'</font>';
158
-                 }
159
-
160
-                 return;
161
-             }
162
-
163
-             $transObtained = $data->responseData->translatedText;
164
-
165
-             $this->translation = ucfirst(strtolower(trim($transObtained)));
166
-
167
-
168
-             // Checking debug setting to determinate how to output translation
169
-
170
-             if ($this->debug == true) {
171
-                 $errors = '';
172
-                 $words = explode(' ', $transObtained);
173
-                 foreach ($words as $word) {
174
-                     if ($word != '') {
175
-                         if ($word[0] == '*') {
176
-                             $errors = $errors.substr($word, 1).', ';
177
-                         }
178
-                     }
179
-                 }
180
-
181
-                 if ($errors == '') {
182
-                     $this->translation = "<font style='color:#00CC00;'>".$this->translation.'</font>';
183
-                 } else {
184
-                     $this->translation = "<font style='color:orange;'>Unknoun words: ".substr($errors, 0, -2).'</font>';
185
-                 }
186
-             }
187
-
188
-             fclose($socket);
189
-
190
-             return;
191
-         } else {
192
-
193
-             // host offline
194
-
195
-             if ($this->debug == true) {
196
-                 $this->translation = "<font style='color:red;'>Mymeory host is down</font>";
197
-             }
198
-
199
-             return;
200
-         }
201
-     }
133
+        /**
134
+         * Get translation from mymemory API.
135
+         */
136
+        public function mymemoryTrans()
137
+        {
138
+            // Check if it can be translated from online sources.
139
+
140
+            $host = 'api.mymemory.translated.net';
141
+            if ($socket = @fsockopen($host, 80, $errno, $errstr, 30)) {
142
+
143
+                // Host online
144
+                $urlString = urlencode($this->string);
145
+                $url = "http://$host/get?q=$urlString&langpair=$this->from%7C$this->to";
146
+                $json = file_get_contents($url);
147
+                $data = json_decode($json);
148
+
149
+                // Checking response status
150
+
151
+                if ($data->responseStatus != 200) {
152
+                    if ($this->debug == true) {
153
+                        $details = $data->responseDetails;
154
+                        if ($data->responseStatus == 403) {
155
+                            $details = ($data->responseDetails);
156
+                        }
157
+                        $this->translation = "<font style='color:red;'>Error ".$data->responseStatus.': '.$details.'</font>';
158
+                    }
159
+
160
+                    return;
161
+                }
162
+
163
+                $transObtained = $data->responseData->translatedText;
164
+
165
+                $this->translation = ucfirst(strtolower(trim($transObtained)));
166
+
167
+
168
+                // Checking debug setting to determinate how to output translation
169
+
170
+                if ($this->debug == true) {
171
+                    $errors = '';
172
+                    $words = explode(' ', $transObtained);
173
+                    foreach ($words as $word) {
174
+                        if ($word != '') {
175
+                            if ($word[0] == '*') {
176
+                                $errors = $errors.substr($word, 1).', ';
177
+                            }
178
+                        }
179
+                    }
180
+
181
+                    if ($errors == '') {
182
+                        $this->translation = "<font style='color:#00CC00;'>".$this->translation.'</font>';
183
+                    } else {
184
+                        $this->translation = "<font style='color:orange;'>Unknoun words: ".substr($errors, 0, -2).'</font>';
185
+                    }
186
+                }
187
+
188
+                fclose($socket);
189
+
190
+                return;
191
+            } else {
192
+
193
+                // host offline
194
+
195
+                if ($this->debug == true) {
196
+                    $this->translation = "<font style='color:red;'>Mymeory host is down</font>";
197
+                }
198
+
199
+                return;
200
+            }
201
+        }
202 202
 
203 203
     /**
204 204
      * Get translation from apertium API.
Please login to merge, or discard this patch.
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -109,7 +109,7 @@  discard block
 block discarded – undo
109 109
         }
110 110
 
111 111
 
112
-        $available_transoltors = ['apertium', 'mymemory'];
112
+        $available_transoltors = [ 'apertium', 'mymemory' ];
113 113
 
114 114
         // Checks available translators.
115 115
 
@@ -172,7 +172,7 @@  discard block
 block discarded – undo
172 172
                  $words = explode(' ', $transObtained);
173 173
                  foreach ($words as $word) {
174 174
                      if ($word != '') {
175
-                         if ($word[0] == '*') {
175
+                         if ($word[ 0 ] == '*') {
176 176
                              $errors = $errors.substr($word, 1).', ';
177 177
                          }
178 178
                      }
@@ -240,7 +240,7 @@  discard block
 block discarded – undo
240 240
                 $words = explode(' ', $transObtained);
241 241
                 foreach ($words as $word) {
242 242
                     if ($word != '') {
243
-                        if ($word[0] == '*') {
243
+                        if ($word[ 0 ] == '*') {
244 244
                             $errors = $errors.substr($word, 1).', ';
245 245
                         }
246 246
                     }
Please login to merge, or discard this patch.