Completed
Push — master ( 82e2b9...ad7cbe )
by Aitor Riba
14:59 queued 04:37
created
src/Facades/Laralang.php 1 patch
Doc Comments   +1 added lines, -3 removed lines patch added patch discarded remove patch
@@ -11,10 +11,8 @@
 block discarded – undo
11 11
      * Get the trnaslation.
12 12
      *
13 13
      * @param string $string
14
-     * @param string $from
15
-     * @param string $to
16 14
      *
17
-     * @return string method of object
15
+     * @return Translation method of object
18 16
      */
19 17
     public static function trans($string)
20 18
     {
Please login to merge, or discard this patch.
src/Translation.php 3 patches
Doc Comments   -2 removed lines patch added patch discarded remove patch
@@ -20,8 +20,6 @@
 block discarded – undo
20 20
      * Setup default values.
21 21
      *
22 22
      * @param string $string
23
-     * @param string $from
24
-     * @param string $to
25 23
      */
26 24
     public function __construct($string)
27 25
     {
Please login to merge, or discard this patch.
Indentation   +65 added lines, -65 removed lines patch added patch discarded remove patch
@@ -140,71 +140,71 @@
 block discarded – undo
140 140
     /**
141 141
      * Get translation from mymemory API.
142 142
      */
143
-     public function mymemoryTrans()
144
-     {
145
-         // Check if it can be translated from online sources.
146
-
147
-         $host = 'api.mymemory.translated.net';
148
-         if($socket =@ fsockopen($host, 80, $errno, $errstr, 30)) {
149
-
150
-             // Host online
151
-             $urlString = urlencode($this->string);
152
-             $url = "http://$host/get?q=$urlString&langpair=$this->from%7C$this->to";
153
-             $json = file_get_contents($url);
154
-             $data = json_decode($json);
155
-
156
-             // Checking response status
157
-
158
-             if ($data->responseStatus != 200) {
159
-                 if ($this->debug == true) {
160
-                     $details = $data->responseDetails;
161
-                     if ($data->responseStatus == 403) {
162
-                         $details =($data->responseDetails);
163
-                     }
164
-                     $this->translation = "<font style='color:red;'>Error ".$data->responseStatus.": ".$details."</font>";
165
-                 }
166
-
167
-                 return;
168
-             }
169
-
170
-             $transObtained = $data->responseData->translatedText;
171
-
172
-             $this->translation = ucfirst(strtolower(trim($transObtained)));
173
-
174
-
175
-             // Checking debug setting to determinate how to output translation
176
-
177
-             if ($this->debug == true) {
178
-                 $errors = '';
179
-                 $words = explode(' ', $transObtained);
180
-                 foreach ($words as $word) {
181
-                     if ($word != '') {
182
-                         if ($word[0] == '*') {
183
-                             $errors = $errors.substr($word, 1).', ';
184
-                         }
185
-                     }
186
-                 }
187
-
188
-                 if ($errors == '') {
189
-                     $this->translation = "<font style='color:#00CC00;'>".$this->translation."</font>";
190
-                 } else {
191
-                     $this->translation = "<font style='color:orange;'>Unknoun words: ".substr($errors, 0, -2)."</font>";
192
-                 }
193
-             }
194
-
195
-             fclose($socket);
196
-             return;
197
-
198
-         } else {
199
-
200
-             // host offline
201
-
202
-             if ($this->debug == true) {
203
-                 $this->translation = "<font style='color:red;'>Mymeory host is down</font>";
204
-             }
205
-             return;
206
-         }
207
-     }
143
+        public function mymemoryTrans()
144
+        {
145
+            // Check if it can be translated from online sources.
146
+
147
+            $host = 'api.mymemory.translated.net';
148
+            if($socket =@ fsockopen($host, 80, $errno, $errstr, 30)) {
149
+
150
+                // Host online
151
+                $urlString = urlencode($this->string);
152
+                $url = "http://$host/get?q=$urlString&langpair=$this->from%7C$this->to";
153
+                $json = file_get_contents($url);
154
+                $data = json_decode($json);
155
+
156
+                // Checking response status
157
+
158
+                if ($data->responseStatus != 200) {
159
+                    if ($this->debug == true) {
160
+                        $details = $data->responseDetails;
161
+                        if ($data->responseStatus == 403) {
162
+                            $details =($data->responseDetails);
163
+                        }
164
+                        $this->translation = "<font style='color:red;'>Error ".$data->responseStatus.": ".$details."</font>";
165
+                    }
166
+
167
+                    return;
168
+                }
169
+
170
+                $transObtained = $data->responseData->translatedText;
171
+
172
+                $this->translation = ucfirst(strtolower(trim($transObtained)));
173
+
174
+
175
+                // Checking debug setting to determinate how to output translation
176
+
177
+                if ($this->debug == true) {
178
+                    $errors = '';
179
+                    $words = explode(' ', $transObtained);
180
+                    foreach ($words as $word) {
181
+                        if ($word != '') {
182
+                            if ($word[0] == '*') {
183
+                                $errors = $errors.substr($word, 1).', ';
184
+                            }
185
+                        }
186
+                    }
187
+
188
+                    if ($errors == '') {
189
+                        $this->translation = "<font style='color:#00CC00;'>".$this->translation."</font>";
190
+                    } else {
191
+                        $this->translation = "<font style='color:orange;'>Unknoun words: ".substr($errors, 0, -2)."</font>";
192
+                    }
193
+                }
194
+
195
+                fclose($socket);
196
+                return;
197
+
198
+            } else {
199
+
200
+                // host offline
201
+
202
+                if ($this->debug == true) {
203
+                    $this->translation = "<font style='color:red;'>Mymeory host is down</font>";
204
+                }
205
+                return;
206
+            }
207
+        }
208 208
 
209 209
     /**
210 210
      * Get translation from apertium API.
Please login to merge, or discard this patch.
Spacing   +8 added lines, -8 removed lines patch added patch discarded remove patch
@@ -35,9 +35,9 @@  discard block
 block discarded – undo
35 35
 
36 36
         // Checking whether from_lang or to_lang are set as app_locale.
37 37
 
38
-        if ($this->from == 'app_locale') {$this->from = App::getLocale();}
38
+        if ($this->from == 'app_locale') {$this->from = App::getLocale(); }
39 39
 
40
-        if ($this->to == 'app_locale') {$this->to = App::getLocale();}
40
+        if ($this->to == 'app_locale') {$this->to = App::getLocale(); }
41 41
     }
42 42
 
43 43
 
@@ -115,7 +115,7 @@  discard block
 block discarded – undo
115 115
         }
116 116
 
117 117
 
118
-        $available_transoltors = ['apertium', 'mymemory'];
118
+        $available_transoltors = [ 'apertium', 'mymemory' ];
119 119
 
120 120
         // Checks available translators.
121 121
 
@@ -145,7 +145,7 @@  discard block
 block discarded – undo
145 145
          // Check if it can be translated from online sources.
146 146
 
147 147
          $host = 'api.mymemory.translated.net';
148
-         if($socket =@ fsockopen($host, 80, $errno, $errstr, 30)) {
148
+         if ($socket = @ fsockopen($host, 80, $errno, $errstr, 30)) {
149 149
 
150 150
              // Host online
151 151
              $urlString = urlencode($this->string);
@@ -159,7 +159,7 @@  discard block
 block discarded – undo
159 159
                  if ($this->debug == true) {
160 160
                      $details = $data->responseDetails;
161 161
                      if ($data->responseStatus == 403) {
162
-                         $details =($data->responseDetails);
162
+                         $details = ($data->responseDetails);
163 163
                      }
164 164
                      $this->translation = "<font style='color:red;'>Error ".$data->responseStatus.": ".$details."</font>";
165 165
                  }
@@ -179,7 +179,7 @@  discard block
 block discarded – undo
179 179
                  $words = explode(' ', $transObtained);
180 180
                  foreach ($words as $word) {
181 181
                      if ($word != '') {
182
-                         if ($word[0] == '*') {
182
+                         if ($word[ 0 ] == '*') {
183 183
                              $errors = $errors.substr($word, 1).', ';
184 184
                          }
185 185
                      }
@@ -215,7 +215,7 @@  discard block
 block discarded – undo
215 215
         // Check if it can be translated from online sources.
216 216
 
217 217
         $host = 'api.apertium.org';
218
-        if($socket =@ fsockopen($host, 80, $errno, $errstr, 30)) {
218
+        if ($socket = @ fsockopen($host, 80, $errno, $errstr, 30)) {
219 219
 
220 220
             // Host online
221 221
 
@@ -247,7 +247,7 @@  discard block
 block discarded – undo
247 247
                 $words = explode(' ', $transObtained);
248 248
                 foreach ($words as $word) {
249 249
                     if ($word != '') {
250
-                        if ($word[0] == '*') {
250
+                        if ($word[ 0 ] == '*') {
251 251
                             $errors = $errors.substr($word, 1).', ';
252 252
                         }
253 253
                     }
Please login to merge, or discard this patch.