Passed
Branch release/v1.2.0 (b943d9)
by Alexander
03:09
created
src/Provider/TranslatorProvider.php 2 patches
Spacing   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -24,9 +24,9 @@  discard block
 block discarded – undo
24 24
      */
25 25
     public function register()
26 26
     {
27
-        $this->mergeConfigFrom(__DIR__.'/../config/translator.php', 'translator');
27
+        $this->mergeConfigFrom(__DIR__ . '/../config/translator.php', 'translator');
28 28
 
29
-        $this->app->singleton('Translator', function () {
29
+        $this->app->singleton('Translator', function() {
30 30
                 return new Translator();
31 31
             }
32 32
         );
@@ -43,9 +43,9 @@  discard block
 block discarded – undo
43 43
             'config'
44 44
         );
45 45
 
46
-        $this->loadMigrationsFrom(__DIR__.'/../migrations/');
47
-        $this->loadRoutesFrom(__DIR__.'/../resources/routes.php');
48
-        $this->loadViewsFrom(__DIR__.'/../resources/views', 'translator');
46
+        $this->loadMigrationsFrom(__DIR__ . '/../migrations/');
47
+        $this->loadRoutesFrom(__DIR__ . '/../resources/routes.php');
48
+        $this->loadViewsFrom(__DIR__ . '/../resources/views', 'translator');
49 49
 
50 50
         if ($this->app->runningInConsole()) {
51 51
             $this->commands([
Please login to merge, or discard this patch.
Braces   +2 added lines, -4 removed lines patch added patch discarded remove patch
@@ -22,8 +22,7 @@  discard block
 block discarded – undo
22 22
     /**
23 23
      * Register any application services.
24 24
      */
25
-    public function register()
26
-    {
25
+    public function register() {
27 26
         $this->mergeConfigFrom(__DIR__.'/../config/translator.php', 'translator');
28 27
 
29 28
         $this->app->singleton('Translator', function () {
@@ -35,8 +34,7 @@  discard block
 block discarded – undo
35 34
     /**
36 35
      * Bootstrap any application services.
37 36
      */
38
-    public function boot()
39
-    {
37
+    public function boot() {
40 38
         $this->publishes([
41 39
                 __DIR__ . '/../config/translator.php' => config_path('translator.php'),
42 40
             ],
Please login to merge, or discard this patch.
src/Controllers/TranslatorAdminController.php 2 patches
Spacing   +8 added lines, -8 removed lines patch added patch discarded remove patch
@@ -35,7 +35,7 @@  discard block
 block discarded – undo
35 35
         $query = TranslationIdentifier::with('translations');
36 36
 
37 37
         if ($locale != '') {
38
-            $query = $query->whereDoesntHave('translations', function ($query) use ($locale)
38
+            $query = $query->whereDoesntHave('translations', function($query) use ($locale)
39 39
                 {
40 40
                     $query->where('translations.locale', 'like', $locale);
41 41
                 }
@@ -43,12 +43,12 @@  discard block
 block discarded – undo
43 43
         }
44 44
 
45 45
         if ($search != '') {
46
-            $query = $query->where(function ($query) use ($search) {
47
-                $query ->where('identifier',     'LIKE', '%'.$search.'%')
48
-                    ->orWhere('parameters', 'LIKE', '%'.$search.'%')
49
-                    ->orWhere('group',      'LIKE', '%'.$search.'%')
50
-                    ->orWhere('page_name',  'LIKE', '%'.$search.'%')
51
-                    ->orWhere('description','LIKE', '%'.$search.'%');
46
+            $query = $query->where(function($query) use ($search) {
47
+                $query ->where('identifier', 'LIKE', '%' . $search . '%')
48
+                    ->orWhere('parameters', 'LIKE', '%' . $search . '%')
49
+                    ->orWhere('group', 'LIKE', '%' . $search . '%')
50
+                    ->orWhere('page_name', 'LIKE', '%' . $search . '%')
51
+                    ->orWhere('description', 'LIKE', '%' . $search . '%');
52 52
             });
53 53
         }
54 54
 
@@ -168,7 +168,7 @@  discard block
 block discarded – undo
168 168
      * @param $state string 'enabled|disabled'
169 169
      * @return \Illuminate\Http\RedirectResponse
170 170
      */
171
-    public function changeLiveMode ($state)
171
+    public function changeLiveMode($state)
172 172
     {
173 173
         if ($state == 'enable') {
174 174
             session(['translation_live_mode' => true]);
Please login to merge, or discard this patch.
Braces   +7 added lines, -14 removed lines patch added patch discarded remove patch
@@ -27,16 +27,14 @@  discard block
 block discarded – undo
27 27
      *
28 28
      * @return \Illuminate\Contracts\View\Factory|\Illuminate\View\View
29 29
      */
30
-    public function index()
31
-    {
30
+    public function index() {
32 31
         $search = Input::get('search', '');
33 32
         $locale = Input::get('locale', '');
34 33
 
35 34
         $query = TranslationIdentifier::with('translations');
36 35
 
37 36
         if ($locale != '') {
38
-            $query = $query->whereDoesntHave('translations', function ($query) use ($locale)
39
-                {
37
+            $query = $query->whereDoesntHave('translations', function ($query) use ($locale) {
40 38
                     $query->where('translations.locale', 'like', $locale);
41 39
                 }
42 40
             );
@@ -73,8 +71,7 @@  discard block
 block discarded – undo
73 71
      * @param integer $id ID of the translation Identifier to edit
74 72
      * @return \Illuminate\Contracts\View\Factory|\Illuminate\View\View
75 73
      */
76
-    public function edit($id)
77
-    {
74
+    public function edit($id) {
78 75
         $identifier = TranslationIdentifier::findOrFail($id);
79 76
 
80 77
         $available_locales = TranslatorFacade::getConfigValue('available_locales');
@@ -97,8 +94,7 @@  discard block
 block discarded – undo
97 94
      * @param Request $request Object with the values of the identifier
98 95
      * @return \Illuminate\Contracts\View\Factory|\Illuminate\View\View
99 96
      */
100
-    public function postEdit($id, Request $request)
101
-    {
97
+    public function postEdit($id, Request $request) {
102 98
         TranslationIdentifier::findOrFail($id);
103 99
 
104 100
         foreach ($request->all() as $key => $value) {
@@ -131,8 +127,7 @@  discard block
 block discarded – undo
131 127
      * @param Request $request Request with multiple values of identifiers to update
132 128
      * @return \Illuminate\Contracts\View\Factory|\Illuminate\View\View
133 129
      */
134
-    public function postIdentifier(Request $request)
135
-    {
130
+    public function postIdentifier(Request $request) {
136 131
         /** @var TranslationIdentifier $translation_identifiers */
137 132
         $translation_identifiers = TranslationIdentifier::all()->whereIn('id', array_keys($request->all()));
138 133
 
@@ -159,8 +154,7 @@  discard block
 block discarded – undo
159 154
      *
160 155
      * @return \Illuminate\Contracts\View\Factory|\Illuminate\View\View
161 156
      */
162
-    public function test()
163
-    {
157
+    public function test() {
164 158
         return view('translator::test');
165 159
     }
166 160
 
@@ -168,8 +162,7 @@  discard block
 block discarded – undo
168 162
      * @param $state string 'enabled|disabled'
169 163
      * @return \Illuminate\Http\RedirectResponse
170 164
      */
171
-    public function changeLiveMode ($state)
172
-    {
165
+    public function changeLiveMode ($state) {
173 166
         if ($state == 'enable') {
174 167
             session(['translation_live_mode' => true]);
175 168
         } else {
Please login to merge, or discard this patch.
src/Middleware/TranslatorMiddleware.php 1 patch
Braces   +1 added lines, -2 removed lines patch added patch discarded remove patch
@@ -30,8 +30,7 @@
 block discarded – undo
30 30
      *
31 31
      * @todo Validate Browser locale string (https://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html#sec14.4)
32 32
      */
33
-    public function handle(Request $request, Closure $next)
34
-    {
33
+    public function handle(Request $request, Closure $next) {
35 34
         if (Session::has('locale') || auth()->check()) {
36 35
             $locale = Session::has('locale') ? session()->get('locale') : auth()->user()->language;
37 36
 
Please login to merge, or discard this patch.
src/Handler/DefaultHandler.php 2 patches
Spacing   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -48,7 +48,7 @@  discard block
 block discarded – undo
48 48
      *
49 49
      * @param $locale
50 50
      */
51
-    function __construct($locale){
51
+    function __construct($locale) {
52 52
         $this->locale = $locale;
53 53
     }
54 54
 
@@ -57,7 +57,7 @@  discard block
 block discarded – undo
57 57
      *
58 58
      * @return string
59 59
      */
60
-    function getLocale(){
60
+    function getLocale() {
61 61
         return $this->locale;
62 62
     }
63 63
 
@@ -68,7 +68,7 @@  discard block
 block discarded – undo
68 68
      * @param string $group
69 69
      * @return string
70 70
      */
71
-    function getTranslation($identifier, $group){
71
+    function getTranslation($identifier, $group) {
72 72
         return $identifier;
73 73
     }
74 74
 
@@ -77,7 +77,7 @@  discard block
 block discarded – undo
77 77
      *
78 78
      * @return bool
79 79
      */
80
-    function refreshCache(){
80
+    function refreshCache() {
81 81
         return true;
82 82
     }
83 83
 
@@ -87,7 +87,7 @@  discard block
 block discarded – undo
87 87
      * @param string $group
88 88
      * @return array
89 89
      */
90
-    function getAllTranslations($group){
90
+    function getAllTranslations($group) {
91 91
         return [];
92 92
     }
93 93
 
Please login to merge, or discard this patch.
Braces   +14 added lines, -8 removed lines patch added patch discarded remove patch
@@ -16,21 +16,27 @@  discard block
 block discarded – undo
16 16
  *
17 17
  * Class TranslationNotFoundException
18 18
  */
19
-class TranslationNotFoundException extends \Exception {}
19
+class TranslationNotFoundException extends \Exception
20
+{
21
+}
20 22
 
21 23
 /**
22 24
  * Custom Exception to distinguish if the Translation Identifier was not found in Cache but could be in DB
23 25
  *
24 26
  * Class TranslationNotInCacheException
25 27
  */
26
-class TranslationNotInCacheException extends TranslationNotFoundException {}
28
+class TranslationNotInCacheException extends TranslationNotFoundException
29
+{
30
+}
27 31
 
28 32
 /**
29 33
  * Custom Exception thrown when a cache file could not be found
30 34
  *
31 35
  * Class TranslationCacheNotFound
32 36
  */
33
-class TranslationCacheNotFound extends \Exception {}
37
+class TranslationCacheNotFound extends \Exception
38
+{
39
+}
34 40
 
35 41
 /**
36 42
  * Interface HandlerInterface
@@ -48,7 +54,7 @@  discard block
 block discarded – undo
48 54
      *
49 55
      * @param $locale
50 56
      */
51
-    function __construct($locale){
57
+    function __construct($locale) {
52 58
         $this->locale = $locale;
53 59
     }
54 60
 
@@ -57,7 +63,7 @@  discard block
 block discarded – undo
57 63
      *
58 64
      * @return string
59 65
      */
60
-    function getLocale(){
66
+    function getLocale() {
61 67
         return $this->locale;
62 68
     }
63 69
 
@@ -68,7 +74,7 @@  discard block
 block discarded – undo
68 74
      * @param string $group
69 75
      * @return string
70 76
      */
71
-    function getTranslation($identifier, $group){
77
+    function getTranslation($identifier, $group) {
72 78
         return $identifier;
73 79
     }
74 80
 
@@ -77,7 +83,7 @@  discard block
 block discarded – undo
77 83
      *
78 84
      * @return bool
79 85
      */
80
-    function refreshCache(){
86
+    function refreshCache() {
81 87
         return true;
82 88
     }
83 89
 
@@ -87,7 +93,7 @@  discard block
 block discarded – undo
87 93
      * @param string $group
88 94
      * @return array
89 95
      */
90
-    function getAllTranslations($group){
96
+    function getAllTranslations($group) {
91 97
         return [];
92 98
     }
93 99
 
Please login to merge, or discard this patch.
src/Handler/DatabaseHandler.php 2 patches
Spacing   +6 added lines, -6 removed lines patch added patch discarded remove patch
@@ -42,11 +42,11 @@  discard block
 block discarded – undo
42 42
     {
43 43
         if (isset($this->translations[$identifier])) {
44 44
             if ($this->translations[$identifier]->translation == null) {
45
-                throw new TranslationNotFoundException("The translation for identifier '".$identifier."' and locale '".$this->locale."' could not be found");
45
+                throw new TranslationNotFoundException("The translation for identifier '" . $identifier . "' and locale '" . $this->locale . "' could not be found");
46 46
             }
47 47
             return $this->translations[$identifier]->translation;
48 48
         } else {
49
-            throw new NotFoundResourceException("The translation identifier '".$identifier."' could not be found");
49
+            throw new NotFoundResourceException("The translation identifier '" . $identifier . "' could not be found");
50 50
         }
51 51
     }
52 52
 
@@ -58,9 +58,9 @@  discard block
 block discarded – undo
58 58
     public function refreshCache()
59 59
     {
60 60
         $translations = new TranslationIdentifier();
61
-        $translations = $translations->leftJoin('translations', function ($join)
61
+        $translations = $translations->leftJoin('translations', function($join)
62 62
             {
63
-                $join->on( 'translation_identifiers.id', '=', 'translations.translation_identifier_id')
63
+                $join->on('translation_identifiers.id', '=', 'translations.translation_identifier_id')
64 64
                     ->where('locale', $this->locale);
65 65
             }
66 66
             )->get();
@@ -98,10 +98,10 @@  discard block
 block discarded – undo
98 98
      */
99 99
     function getDatabaseID($identifier)
100 100
     {
101
-        if(isset($this->translations[$identifier])) {
101
+        if (isset($this->translations[$identifier])) {
102 102
             return $this->translations[$identifier]->id;
103 103
         } else {
104
-            throw new NotFoundResourceException("The translation identifier '".$identifier."' could not be found");
104
+            throw new NotFoundResourceException("The translation identifier '" . $identifier . "' could not be found");
105 105
         }
106 106
     }
107 107
 }
108 108
\ No newline at end of file
Please login to merge, or discard this patch.
Braces   +6 added lines, -12 removed lines patch added patch discarded remove patch
@@ -22,8 +22,7 @@  discard block
 block discarded – undo
22 22
      *
23 23
      * @param string $locale The locale of the translations
24 24
      */
25
-    public function __construct($locale)
26
-    {
25
+    public function __construct($locale) {
27 26
         parent::__construct($locale);
28 27
 
29 28
         $this->refreshCache();
@@ -38,8 +37,7 @@  discard block
 block discarded – undo
38 37
      * @throws TranslationNotFoundException
39 38
      * @return string returns the found translation for identifier
40 39
      */
41
-    public function getTranslation($identifier, $group)
42
-    {
40
+    public function getTranslation($identifier, $group) {
43 41
         if (isset($this->translations[$identifier])) {
44 42
             if ($this->translations[$identifier]->translation == null) {
45 43
                 throw new TranslationNotFoundException("The translation for identifier '".$identifier."' and locale '".$this->locale."' could not be found");
@@ -55,11 +53,9 @@  discard block
 block discarded – undo
55 53
      *
56 54
      * @return void
57 55
      */
58
-    public function refreshCache()
59
-    {
56
+    public function refreshCache() {
60 57
         $translations = new TranslationIdentifier();
61
-        $translations = $translations->leftJoin('translations', function ($join)
62
-            {
58
+        $translations = $translations->leftJoin('translations', function ($join) {
63 59
                 $join->on( 'translation_identifiers.id', '=', 'translations.translation_identifier_id')
64 60
                     ->where('locale', $this->locale);
65 61
             }
@@ -76,8 +72,7 @@  discard block
 block discarded – undo
76 72
      * @param string $group Group of the translations to return
77 73
      * @return array Translations of the given group
78 74
      */
79
-    public function getAllTranslations($group = 'default')
80
-    {
75
+    public function getAllTranslations($group = 'default') {
81 76
         $return = [];
82 77
         foreach (collect($this->translations)->where('group', $group) as $key => $translation) {
83 78
             if ($translation->translation == null) {
@@ -96,8 +91,7 @@  discard block
 block discarded – undo
96 91
      * @throws NotFoundResourceException
97 92
      * @return integer
98 93
      */
99
-    function getDatabaseID($identifier)
100
-    {
94
+    function getDatabaseID($identifier) {
101 95
         if(isset($this->translations[$identifier])) {
102 96
             return $this->translations[$identifier]->id;
103 97
         } else {
Please login to merge, or discard this patch.