Completed
Push — master ( 5e66cb...a4355a )
by Chukwudiebube
07:08
created
src/TranslationServiceProvider.php 1 patch
Braces   +4 added lines, -1 removed lines patch added patch discarded remove patch
@@ -34,7 +34,10 @@
 block discarded – undo
34 34
      */
35 35
     public function register()
36 36
     {
37
-        if (PHP_SESSION_NONE == session_status()) session_start(); // Start Session
37
+        if (PHP_SESSION_NONE == session_status()) {
38
+            session_start();
39
+        }
40
+        // Start Session
38 41
 
39 42
         // Allow configuration to be publishable.
40 43
         $this->publishes([
Please login to merge, or discard this patch.
src/Translation.php 1 patch
Braces   +18 added lines, -6 removed lines patch added patch discarded remove patch
@@ -187,7 +187,9 @@  discard block
 block discarded – undo
187 187
             throw new InvalidArgumentException( $message );
188 188
         }
189 189
 
190
-        if ( empty( $text ) ) return $text;
190
+        if ( empty( $text ) ) {
191
+            return $text;
192
+        }
191 193
 
192 194
         // Get translation data from session or database
193 195
         $translations = (array) ($_SESSION['__translations'] ?? $this->translationModel->pluck( 'data', 'text' )->toArray());
@@ -254,16 +256,22 @@  discard block
 block discarded – undo
254 256
         $new_translations = $_SESSION['__translations'] ?? [];
255 257
         $old_translations = (array) $this->translationModel->pluck( 'data', 'text' )->toArray();
256 258
 
257
-        if ( json_encode( $new_translations ) == json_encode( $old_translations ) ) return;
259
+        if ( json_encode( $new_translations ) == json_encode( $old_translations ) ) {
260
+            return;
261
+        }
258 262
 
259 263
         $now = Carbon::now('utc')->toDateTimeString();
260 264
         $insert = $update = [];
261 265
 
262
-        if ( empty( $new_translations ) ) return;
266
+        if ( empty( $new_translations ) ) {
267
+            return;
268
+        }
263 269
 
264 270
         foreach ($new_translations as $text => $data) {
265 271
             if ( isset( $old_translations[ $text ] ) ) {
266
-                if ( $old_translations[ $text ] == $data ) continue;
272
+                if ( $old_translations[ $text ] == $data ) {
273
+                    continue;
274
+                }
267 275
 
268 276
                 // Update old
269 277
                 $this->translationModel->where( 'text', $text )->update( [ 'data' => $data ] );
@@ -279,9 +287,13 @@  discard block
 block discarded – undo
279 287
             ];
280 288
         }
281 289
 
282
-        if ( ! empty( $insert ) ) $this->translationModel->insert( $insert );
290
+        if ( ! empty( $insert ) ) {
291
+            $this->translationModel->insert( $insert );
292
+        }
283 293
 
284 294
         // Remove the translation
285
-        if ( isset( $_SESSION['__translations'] ) ) unset( $_SESSION['__translations'] );
295
+        if ( isset( $_SESSION['__translations'] ) ) {
296
+            unset( $_SESSION['__translations'] );
297
+        }
286 298
     }
287 299
 }
Please login to merge, or discard this patch.