Completed
Push — master ( 9c5452...a7b114 )
by Aitor Riba
02:38 queued 01:10
created
src/Builder/ApertiumTrans.php 1 patch
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -21,15 +21,15 @@  discard block
 block discarded – undo
21 21
 
22 22
             // Checking response status
23 23
 
24
-            if ($data['responseStatus'] != 200) {
24
+            if ($data[ 'responseStatus' ] != 200) {
25 25
                 if ($this->debug === true) {
26
-                    $this->translation = "<font style='color:red;'>Error ".$data['responseStatus'].': '.$data['responseDetails'].'</font>';
26
+                    $this->translation = "<font style='color:red;'>Error ".$data[ 'responseStatus' ].': '.$data[ 'responseDetails' ].'</font>';
27 27
                 }
28 28
 
29 29
                 return;
30 30
             }
31 31
 
32
-            $transObtained = $data['responseData']['translatedText'];
32
+            $transObtained = $data[ 'responseData' ][ 'translatedText' ];
33 33
 
34 34
             $this->translation = ucfirst(strtolower(trim(str_replace('*', ' ', $transObtained))));
35 35
 
@@ -40,7 +40,7 @@  discard block
 block discarded – undo
40 40
                 $words = explode(' ', $transObtained);
41 41
                 foreach ($words as $word) {
42 42
                     if ($word != '') {
43
-                        if ($word[0] == '*') {
43
+                        if ($word[ 0 ] == '*') {
44 44
                             $errors = $errors.substr($word, 1).', ';
45 45
                         }
46 46
                     }
Please login to merge, or discard this patch.
src/Builder/Translation.php 1 patch
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -23,7 +23,7 @@  discard block
 block discarded – undo
23 23
      *
24 24
      * @param string $string
25 25
      */
26
-    public function __construct($string, $vars = [])
26
+    public function __construct($string, $vars = [ ])
27 27
     {
28 28
         $this->translator = config('laralang.default.translator');
29 29
         $this->debug = config('laralang.default.debug');
@@ -120,7 +120,7 @@  discard block
 block discarded – undo
120 120
         if ($this->debug === true) {
121 121
             $this->translation = "<font style='color:#00CC00;'>Translation loaded from DB</font>";
122 122
         } else {
123
-            $this->translation = ($existing[0]->translation);
123
+            $this->translation = ($existing[ 0 ]->translation);
124 124
         }
125 125
 
126 126
         return true;
Please login to merge, or discard this patch.
src/Controllers/LaralangController.php 1 patch
Spacing   +8 added lines, -8 removed lines patch added patch discarded remove patch
@@ -22,7 +22,7 @@  discard block
 block discarded – undo
22 22
 
23 23
     public function login(Request $request)
24 24
     {
25
-        session(['laralang.password' => Crypt::encrypt($request->input('password'))]);
25
+        session([ 'laralang.password' => Crypt::encrypt($request->input('password')) ]);
26 26
         if (Crypt::decrypt(session('laralang.password')) != config('laralang.default.password')) {
27 27
             return redirect(Route('laralang::login'))
28 28
             ->with('status', 'Invalid password');
@@ -50,7 +50,7 @@  discard block
 block discarded – undo
50 50
 
51 51
     public function showTranslationsFilter()
52 52
     {
53
-        return view('laralang::filter', ['languagesFrom' => Laralang::fromLanguages(), 'languagesTo' => Laralang::toLanguages()]);
53
+        return view('laralang::filter', [ 'languagesFrom' => Laralang::fromLanguages(), 'languagesTo' => Laralang::toLanguages() ]);
54 54
     }
55 55
 
56 56
     public function showTranslate()
@@ -66,12 +66,12 @@  discard block
 block discarded – undo
66 66
 
67 67
     public function translationsFilter(Request $request)
68 68
     {
69
-        return redirect(Linker::route('laralang::filterFromTo', [$request->from_lang, $request->to_lang]));
69
+        return redirect(Linker::route('laralang::filterFromTo', [ $request->from_lang, $request->to_lang ]));
70 70
     }
71 71
 
72 72
     public function showTranslationsFiltered($from_lang, $to_lang)
73 73
     {
74
-        return view('laralang::translations', ['from_lang' => $from_lang, 'to_lang' => $to_lang]);
74
+        return view('laralang::translations', [ 'from_lang' => $from_lang, 'to_lang' => $to_lang ]);
75 75
     }
76 76
 
77 77
     public function api()
@@ -83,7 +83,7 @@  discard block
 block discarded – undo
83 83
     {
84 84
         $translatedText = Laralang::trans($request->string)->to($request->to);
85 85
 
86
-        return ['translatedText' => strval($translatedText)];
86
+        return [ 'translatedText' => strval($translatedText) ];
87 87
     }
88 88
 
89 89
     public function apiFilterFromTo($from_lang, $to_lang)
@@ -94,15 +94,15 @@  discard block
 block discarded – undo
94 94
         } elseif ($to_lang == 'all') {
95 95
 
96 96
             //return translation where from_lang == $from
97
-            return DB_Translation::where([['from_lang', $from_lang]])->get();
97
+            return DB_Translation::where([ [ 'from_lang', $from_lang ] ])->get();
98 98
         } elseif ($from_lang == 'all') {
99 99
 
100 100
             //return translation where to_lang == $to
101
-            return DB_Translation::where([['to_lang', $to_lang]])->get();
101
+            return DB_Translation::where([ [ 'to_lang', $to_lang ] ])->get();
102 102
         } else {
103 103
 
104 104
             //return translation where from_lang == $from and to_lang == $to
105
-            return DB_Translation::where([['from_lang', $from_lang], ['to_lang', $to_lang]])->get();
105
+            return DB_Translation::where([ [ 'from_lang', $from_lang ], [ 'to_lang', $to_lang ] ])->get();
106 106
         }
107 107
     }
108 108
 
Please login to merge, or discard this patch.
src/Routes/web.php 1 patch
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -1,15 +1,15 @@  discard block
 block discarded – undo
1 1
 <?php
2 2
 
3 3
 if (config('laralang.default.routes')) {
4
-    Route::group(['middleware' => 'web', 'as' => 'laralang::', 'prefix' => config('laralang.default.prefix'), 'namespace' => 'Aitor24\Laralang\Controllers'], function () {
4
+    Route::group([ 'middleware' => 'web', 'as' => 'laralang::', 'prefix' => config('laralang.default.prefix'), 'namespace' => 'Aitor24\Laralang\Controllers' ], function() {
5 5
         Route::get('/login', 'LaralangController@showLogin')->name('login');
6 6
         Route::post('/login', 'LaralangController@login');
7 7
         if (config('laralang.default.api')) {
8
-            Route::group(['middleware' => ['throttle:5000,1', 'bindings']], function () {
8
+            Route::group([ 'middleware' => [ 'throttle:5000,1', 'bindings' ] ], function() {
9 9
                 Route::post('/api/translate', 'LaralangController@apiTranslate')->name('apiTranslate');
10 10
             });
11 11
         }
12
-        Route::group(['middleware' => 'laralang.middleware'], function () {
12
+        Route::group([ 'middleware' => 'laralang.middleware' ], function() {
13 13
             Route::get('/', 'LaralangController@index')->name('index');
14 14
             Route::get('/translations', 'LaralangController@showTranslations')->name('translations');
15 15
 
@@ -26,7 +26,7 @@  discard block
 block discarded – undo
26 26
             Route::post('/edit', 'LaralangController@editTranslation')->name('editTrans');
27 27
             Route::get('/logout', 'LaralangController@logout')->name('logout');
28 28
 
29
-            Route::group(['middleware' => ['throttle:5000,1', 'bindings']], function () {
29
+            Route::group([ 'middleware' => [ 'throttle:5000,1', 'bindings' ] ], function() {
30 30
                 Route::get('/api', 'LaralangController@api')->name('api');
31 31
                 Route::get('/api/filter/from/{from_lang}/to/{to_lang}', 'LaralangController@apiFilterFromTo')->name('apiFilterFromTo');
32 32
             });
Please login to merge, or discard this patch.
src/Builder.php 2 patches
Doc Comments   -1 removed lines patch added patch discarded remove patch
@@ -35,7 +35,6 @@
 block discarded – undo
35 35
     /**
36 36
      * Generate files json for a specify package.
37 37
      *
38
-     * @param string $string
39 38
      *
40 39
      * @return object
41 40
      */
Please login to merge, or discard this patch.
Spacing   +7 added lines, -7 removed lines patch added patch discarded remove patch
@@ -16,10 +16,10 @@  discard block
 block discarded – undo
16 16
      *
17 17
      * @return object
18 18
      */
19
-    public static function trans($string, $vars = [])
19
+    public static function trans($string, $vars = [ ])
20 20
     {
21 21
         $translator = config('laralang.default.translator');
22
-        if (!in_array(config('laralang.default.translator'), ['apertium', 'mymemory', 'google'])) {
22
+        if (!in_array(config('laralang.default.translator'), [ 'apertium', 'mymemory', 'google' ])) {
23 23
             return "<font style='color:red;'>Laralang doesn't support $translator translator. Check config</font>";
24 24
         } else {
25 25
             if (config('laralang.default.translator') == 'mymemory') {
@@ -66,9 +66,9 @@  discard block
 block discarded – undo
66 66
     private static function transArray($array, $lang)
67 67
     {
68 68
         foreach ($array as $var => $text) {
69
-            $vars = [];
69
+            $vars = [ ];
70 70
             if (is_array($text)) {
71
-                $array[$var] = self::transArray($text, $lang);
71
+                $array[ $var ] = self::transArray($text, $lang);
72 72
             } else {
73 73
                 foreach (explode(' ', $text) as $word) {
74 74
                     if (strpos($word, ':') !== false && mb_substr($word, -1) != ':') {
@@ -79,7 +79,7 @@  discard block
 block discarded – undo
79 79
                 foreach ($vars as $key => $varreplace) {
80 80
                     $entry = str_replace($varreplace, '14741469'.$key, $entry);
81 81
                 }
82
-                $array[$var] = self::trans($entry, $vars)->from('en')->to($lang)->load(false)->Save(false)->__toString();
82
+                $array[ $var ] = self::trans($entry, $vars)->from('en')->to($lang)->load(false)->Save(false)->__toString();
83 83
             }
84 84
         }
85 85
 
@@ -93,7 +93,7 @@  discard block
 block discarded – undo
93 93
      */
94 94
     public static function toLanguages()
95 95
     {
96
-        $locales = [];
96
+        $locales = [ ];
97 97
         $translations = DB_Translation::distinct()->select('to_lang')->get();
98 98
         foreach ($translations as $object) {
99 99
             array_push($locales, $object->to_lang);
@@ -109,7 +109,7 @@  discard block
 block discarded – undo
109 109
      */
110 110
     public static function fromLanguages()
111 111
     {
112
-        $locales = [];
112
+        $locales = [ ];
113 113
         $translations = DB_Translation::distinct()->select('from_lang')->get();
114 114
         foreach ($translations as $object) {
115 115
             array_push($locales, $object->from_lang);
Please login to merge, or discard this patch.
src/Migrations/2016_11_04_135240_laralang_translations.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_translations', function (Blueprint $table) {
16
+        Schema::create('laralang_translations', function(Blueprint $table) {
17 17
             $table->increments('id');
18 18
             $table->string('translator');
19 19
             $table->text('string');
Please login to merge, or discard this patch.
src/Builder/MymemoryTrans.php 2 patches
Indentation   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -14,7 +14,7 @@
 block discarded – undo
14 14
         // Check if host is online.
15 15
         if ($this->checkHost($host)) {
16 16
 
17
-             // Host online
17
+                // Host online
18 18
             $urlString = urlencode($this->string);
19 19
             $urldata = file_get_contents("http://$host/get?q=$urlString&langpair=$this->from|$this->to");
20 20
             $data = json_decode($urldata, true);
Please login to merge, or discard this patch.
Spacing   +8 added lines, -8 removed lines patch added patch discarded remove patch
@@ -19,12 +19,12 @@  discard block
 block discarded – undo
19 19
             $urldata = file_get_contents("http://$host/get?q=$urlString&langpair=$this->from|$this->to");
20 20
             $data = json_decode($urldata, true);
21 21
 
22
-            if ($data['responseStatus'] != 200) {
22
+            if ($data[ 'responseStatus' ] != 200) {
23 23
                 if ($this->debug == true) {
24
-                    if ($data['responseStatus'] == 403) {
25
-                        $details = ($data['responseDetails']);
24
+                    if ($data[ 'responseStatus' ] == 403) {
25
+                        $details = ($data[ 'responseDetails' ]);
26 26
                     } else {
27
-                        $details = $data['responseDetails'];
27
+                        $details = $data[ 'responseDetails' ];
28 28
                     }
29 29
                     $this->translation = "<font style='color:red;'>Error ".$data->responseStatus.': '.$details.'</font>';
30 30
                 }
@@ -33,16 +33,16 @@  discard block
 block discarded – undo
33 33
             }
34 34
 
35 35
             // Checking if any translation provides from 24aitor to use it
36
-            foreach ($data['matches']  as $match) {
37
-                if ($match['last-updated-by'] == '24aitor') {
38
-                    $this->translation = $match['translation'];
36
+            foreach ($data[ 'matches' ]  as $match) {
37
+                if ($match[ 'last-updated-by' ] == '24aitor') {
38
+                    $this->translation = $match[ 'translation' ];
39 39
                     $this->checkSave();
40 40
 
41 41
                     return;
42 42
                 }
43 43
             }
44 44
 
45
-            $this->translation = $data['responseData']['translatedText'];
45
+            $this->translation = $data[ 'responseData' ][ 'translatedText' ];
46 46
             $this->checkSave();
47 47
 
48 48
             return;
Please login to merge, or discard this patch.
src/Builder/GoogleTrans.php 2 patches
Indentation   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -14,7 +14,7 @@
 block discarded – undo
14 14
         // Check if host is online.
15 15
         if ($this->checkHost($host)) {
16 16
 
17
-             // Host online
17
+                // Host online
18 18
             $urlString = urlencode($this->string);
19 19
             $urldata = file_get_contents("https://translate.googleapis.com/translate_a/single?client=gtx&sl=$this->from&tl=$this->to&dt=t&q=$urlString");
20 20
             $tr = $urldata;
Please login to merge, or discard this patch.
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -21,10 +21,10 @@
 block discarded – undo
21 21
             $tr = substr($tr, 3, -6);
22 22
             $tr = $tr.'["';
23 23
             $tr = explode('],[', $tr);
24
-            $trans = [];
24
+            $trans = [ ];
25 25
             foreach ($tr as $tran) {
26 26
                 $transl = explode('","', $tran);
27
-                array_push($trans, str_replace('\"', '"', ucfirst(substr($transl[0], 1))));
27
+                array_push($trans, str_replace('\"', '"', ucfirst(substr($transl[ 0 ], 1))));
28 28
             }
29 29
             $this->translation = trim(implode(' ', $trans));
30 30
             $this->checkSave();
Please login to merge, or discard this patch.