Completed
Push — master ( bb6568...5e5b00 )
by Aitor Riba
02:21
created
src/Translation.php 3 patches
Unused Use Statements   -3 removed lines patch added patch discarded remove patch
@@ -3,11 +3,8 @@
 block discarded – undo
3 3
 namespace Aitor24\Laralang;
4 4
 
5 5
 use App;
6
-
7 6
 use Aitor24\Laralang\Models\DB_Translation;
8
-
9 7
 use Illuminate\Support\Facades\DB;
10
-use App\Http\Controllers\Controller;
11 8
 
12 9
 class Translation
13 10
 {
Please login to merge, or discard this patch.
Indentation   +42 added lines, -42 removed lines patch added patch discarded remove patch
@@ -176,58 +176,58 @@
 block discarded – undo
176 176
         }
177 177
     }
178 178
 
179
-     /**
180
-      * Get translation from mymemory API.
181
-      */
182
-     private function mymemoryTrans()
183
-     {
184
-         // Check if it can be translated from online sources.
185
-
186
-         $host = 'api.mymemory.translated.net';
187
-         if ($socket = @fsockopen($host, 80, $errno, $errstr, 30)) {
188
-
189
-             // Host online
190
-             $urlString = urlencode($this->string);
191
-             $url = "http://$host/get?q=$urlString&langpair=$this->from%7C$this->to";
192
-             $json = file_get_contents($url);
193
-             $data = json_decode($json);
194
-
195
-             // Checking response status
196
-
197
-             if ($data->responseStatus != 200) {
198
-                 if ($this->debug == true) {
199
-                     $details = $data->responseDetails;
200
-                     if ($data->responseStatus == 403) {
201
-                         $details = ($data->responseDetails);
202
-                     }
203
-                     $this->translation = "<font style='color:red;'>Error ".$data->responseStatus.': '.$details.'</font>';
204
-                 }
179
+        /**
180
+         * Get translation from mymemory API.
181
+         */
182
+        private function mymemoryTrans()
183
+        {
184
+            // Check if it can be translated from online sources.
185
+
186
+            $host = 'api.mymemory.translated.net';
187
+            if ($socket = @fsockopen($host, 80, $errno, $errstr, 30)) {
188
+
189
+                // Host online
190
+                $urlString = urlencode($this->string);
191
+                $url = "http://$host/get?q=$urlString&langpair=$this->from%7C$this->to";
192
+                $json = file_get_contents($url);
193
+                $data = json_decode($json);
194
+
195
+                // Checking response status
196
+
197
+                if ($data->responseStatus != 200) {
198
+                    if ($this->debug == true) {
199
+                        $details = $data->responseDetails;
200
+                        if ($data->responseStatus == 403) {
201
+                            $details = ($data->responseDetails);
202
+                        }
203
+                        $this->translation = "<font style='color:red;'>Error ".$data->responseStatus.': '.$details.'</font>';
204
+                    }
205 205
 
206
-                 return;
207
-             }
206
+                    return;
207
+                }
208 208
 
209 209
 
210
-             $transObtained = $data->responseData->translatedText;
210
+                $transObtained = $data->responseData->translatedText;
211 211
 
212
-             $this->translation = utf8_decode(ucfirst(strtolower(trim($transObtained))));
212
+                $this->translation = utf8_decode(ucfirst(strtolower(trim($transObtained))));
213 213
 
214
-             $this->save();
214
+                $this->save();
215 215
 
216
-             // Checking debug setting to determinate how to output translation
216
+                // Checking debug setting to determinate how to output translation
217 217
 
218
-             if ($this->debug === true) {
219
-                 $this->translation = "<font style='color:#00CC00;'>".$this->translation.'</font>';
220
-             }
218
+                if ($this->debug === true) {
219
+                    $this->translation = "<font style='color:#00CC00;'>".$this->translation.'</font>';
220
+                }
221 221
 
222 222
 
223
-             return;
224
-             fclose($socket);
225
-         } else {
223
+                return;
224
+                fclose($socket);
225
+            } else {
226 226
 
227
-             //host offline
228
-             $this->hostDown();
229
-         }
230
-     }
227
+                //host offline
228
+                $this->hostDown();
229
+            }
230
+        }
231 231
 
232 232
     /**
233 233
      * Get translation from apertium API.
Please login to merge, or discard this patch.
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -102,13 +102,13 @@  discard block
 block discarded – undo
102 102
         ->where('to_lang', '=', $this->to)
103 103
         ->where('translator', '=', $this->translator)->get();
104 104
 
105
-        if (count($existing) == 0){
105
+        if (count($existing) == 0) {
106 106
             return false;
107 107
         }
108 108
         if ($this->debug === true) {
109 109
             $this->translation = "<font style='color:#00CC00;'>Loaded correclty from you DB</font>";
110 110
         } else {
111
-            $this->translation = $existing[0]->translation;
111
+            $this->translation = $existing[ 0 ]->translation;
112 112
         }
113 113
         return true;
114 114
 
@@ -157,7 +157,7 @@  discard block
 block discarded – undo
157 157
             return;
158 158
         }
159 159
 
160
-        $available_transoltors = ['apertium', 'mymemory'];
160
+        $available_transoltors = [ 'apertium', 'mymemory' ];
161 161
 
162 162
         // Checks available translators.
163 163
 
@@ -269,7 +269,7 @@  discard block
 block discarded – undo
269 269
                 $words = explode(' ', $transObtained);
270 270
                 foreach ($words as $word) {
271 271
                     if ($word != '') {
272
-                        if ($word[0] == '*') {
272
+                        if ($word[ 0 ] == '*') {
273 273
                             $errors = $errors.substr($word, 1).', ';
274 274
                         }
275 275
                     }
Please login to merge, or discard this patch.
src/Models/DB_Translation.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -8,7 +8,7 @@
 block discarded – undo
8 8
 {
9 9
     protected $table = 'laralang';
10 10
 
11
-    public function getId(){
11
+    public function getId() {
12 12
         return 'Translation_'.$this->id;
13 13
     }
14 14
 }
Please login to merge, or discard this patch.
src/Migrations/2016_11_04_135240_laralang.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -13,7 +13,7 @@
 block discarded – undo
13 13
      */
14 14
     public function up()
15 15
     {
16
-        Schema::create('laralang', function (Blueprint $table) {
16
+        Schema::create('laralang', function(Blueprint $table) {
17 17
             $table->increments('id');
18 18
             $table->string('translator')->default('Unknoun');
19 19
             $table->string('alias')->unique()->default('Unknoun');
Please login to merge, or discard this patch.