Passed
Push — master ( bcce53 )
by Robert
02:48
created
migrations/2014_01_07_073615_create_tagged_table.php 2 patches
Indentation   +16 added lines, -16 removed lines patch added patch discarded remove patch
@@ -5,21 +5,21 @@
 block discarded – undo
5 5
 
6 6
 class CreateTaggedTable extends Migration {
7 7
 
8
-	public function up() {
9
-		Schema::create('tagging_tagged', function(Blueprint $table) {
10
-			$table->increments('id');
11
-			if(config('tagging.primary_keys_type') == 'string') {
12
-				$table->string('taggable_id', 36)->index();
13
-			} else {
14
-				$table->integer('taggable_id')->unsigned()->index();
15
-			}
16
-			$table->string('taggable_type', 125)->index();
17
-			$table->string('tag_name', 125);
18
-			$table->string('tag_slug', 125)->index();
19
-		});
20
-	}
8
+    public function up() {
9
+        Schema::create('tagging_tagged', function(Blueprint $table) {
10
+            $table->increments('id');
11
+            if(config('tagging.primary_keys_type') == 'string') {
12
+                $table->string('taggable_id', 36)->index();
13
+            } else {
14
+                $table->integer('taggable_id')->unsigned()->index();
15
+            }
16
+            $table->string('taggable_type', 125)->index();
17
+            $table->string('tag_name', 125);
18
+            $table->string('tag_slug', 125)->index();
19
+        });
20
+    }
21 21
 
22
-	public function down() {
23
-		Schema::drop('tagging_tagged');
24
-	}
22
+    public function down() {
23
+        Schema::drop('tagging_tagged');
24
+    }
25 25
 }
Please login to merge, or discard this patch.
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -8,7 +8,7 @@
 block discarded – undo
8 8
 	public function up() {
9 9
 		Schema::create('tagging_tagged', function(Blueprint $table) {
10 10
 			$table->increments('id');
11
-			if(config('tagging.primary_keys_type') == 'string') {
11
+			if (config('tagging.primary_keys_type') == 'string') {
12 12
 				$table->string('taggable_id', 36)->index();
13 13
 			} else {
14 14
 				$table->integer('taggable_id')->unsigned()->index();
Please login to merge, or discard this patch.
migrations/2016_06_29_073615_create_tag_groups_table.php 1 patch
Indentation   +12 added lines, -12 removed lines patch added patch discarded remove patch
@@ -5,17 +5,17 @@
 block discarded – undo
5 5
 
6 6
 class CreateTagGroupsTable extends Migration {
7 7
 
8
-	public function up()
9
-	{
10
-		Schema::create('tagging_tag_groups', function(Blueprint $table) {
11
-			$table->increments('id');
12
-			$table->string('slug', 125)->index();
13
-			$table->string('name', 125);
14
-		});
15
-	}
8
+    public function up()
9
+    {
10
+        Schema::create('tagging_tag_groups', function(Blueprint $table) {
11
+            $table->increments('id');
12
+            $table->string('slug', 125)->index();
13
+            $table->string('name', 125);
14
+        });
15
+    }
16 16
 
17
-	public function down()
18
-	{
19
-		Schema::drop('tagging_tag_groups');
20
-	}
17
+    public function down()
18
+    {
19
+        Schema::drop('tagging_tag_groups');
20
+    }
21 21
 }
Please login to merge, or discard this patch.
src/Model/Tag.php 1 patch
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -39,7 +39,7 @@  discard block
 block discarded – undo
39 39
      */
40 40
     public function save(array $options = [])
41 41
     {
42
-        if(strlen($this->name) < 1) {
42
+        if (strlen($this->name) < 1) {
43 43
             throw new \RuntimeException('Cannot save a tag with an empty name');
44 44
         }
45 45
 
@@ -65,7 +65,7 @@  discard block
 block discarded – undo
65 65
 
66 66
             return $this;
67 67
         } else {
68
-            throw new \RuntimeException('No Tag Group found: '. $group);
68
+            throw new \RuntimeException('No Tag Group found: '.$group);
69 69
         }
70 70
     }
71 71
 
@@ -121,7 +121,7 @@  discard block
 block discarded – undo
121 121
     {
122 122
         $groupSlug = TaggingUtility::normalize($groupName);
123 123
 
124
-        return $query->whereHas('group', function (Builder $query) use ($groupSlug) {
124
+        return $query->whereHas('group', function(Builder $query) use ($groupSlug) {
125 125
             $query->where('slug', $groupSlug);
126 126
         });
127 127
     }
Please login to merge, or discard this patch.
migrations/2014_01_07_073615_create_tags_table.php 1 patch
Indentation   +14 added lines, -14 removed lines patch added patch discarded remove patch
@@ -5,20 +5,20 @@
 block discarded – undo
5 5
 
6 6
 class CreateTagsTable extends Migration
7 7
 {
8
-	public function up()
9
-	{
10
-		Schema::create('tagging_tags', function(Blueprint $table) {
11
-			$table->increments('id');
12
-			$table->string('slug', 125)->index();
13
-			$table->string('name', 125);
14
-			$table->boolean('suggest')->default(false);
15
-			$table->integer('count')->unsigned()->default(0); // count of how many times this tag was used
8
+    public function up()
9
+    {
10
+        Schema::create('tagging_tags', function(Blueprint $table) {
11
+            $table->increments('id');
12
+            $table->string('slug', 125)->index();
13
+            $table->string('name', 125);
14
+            $table->boolean('suggest')->default(false);
15
+            $table->integer('count')->unsigned()->default(0); // count of how many times this tag was used
16 16
             $table->integer('tag_group_id')->unsigned()->nullable();
17
-		});
18
-	}
17
+        });
18
+    }
19 19
 
20
-	public function down()
21
-	{
22
-		Schema::drop('tagging_tags');
23
-	}
20
+    public function down()
21
+    {
22
+        Schema::drop('tagging_tags');
23
+    }
24 24
 }
Please login to merge, or discard this patch.
migrations/2016_06_29_073615_update_tags_table.php 2 patches
Indentation   +12 added lines, -12 removed lines patch added patch discarded remove patch
@@ -5,20 +5,20 @@
 block discarded – undo
5 5
 
6 6
 class UpdateTagsTable extends Migration {
7 7
 
8
-	public function up()
9
-	{
10
-		Schema::table('tagging_tags', function ($table) {
11
-			$table->foreign('tag_group_id')->references('id')->on('tagging_tag_groups');
12
-		});
8
+    public function up()
9
+    {
10
+        Schema::table('tagging_tags', function ($table) {
11
+            $table->foreign('tag_group_id')->references('id')->on('tagging_tag_groups');
12
+        });
13 13
 
14
-	}
14
+    }
15 15
 
16 16
 
17
-	public function down()
18
-	{
17
+    public function down()
18
+    {
19 19
         Schema::disableForeignKeyConstraints();
20
-		Schema::table('tagging_tags', function ($table) {
21
-			$table->dropForeign('tagging_tags_tag_group_id_foreign');
22
-		});
23
-	}
20
+        Schema::table('tagging_tags', function ($table) {
21
+            $table->dropForeign('tagging_tags_tag_group_id_foreign');
22
+        });
23
+    }
24 24
 }
Please login to merge, or discard this patch.
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -7,7 +7,7 @@  discard block
 block discarded – undo
7 7
 
8 8
 	public function up()
9 9
 	{
10
-		Schema::table('tagging_tags', function ($table) {
10
+		Schema::table('tagging_tags', function($table) {
11 11
 			$table->foreign('tag_group_id')->references('id')->on('tagging_tag_groups');
12 12
 		});
13 13
 
@@ -17,7 +17,7 @@  discard block
 block discarded – undo
17 17
 	public function down()
18 18
 	{
19 19
         Schema::disableForeignKeyConstraints();
20
-		Schema::table('tagging_tags', function ($table) {
20
+		Schema::table('tagging_tags', function($table) {
21 21
 			$table->dropForeign('tagging_tags_tag_group_id_foreign');
22 22
 		});
23 23
 	}
Please login to merge, or discard this patch.
src/Taggable.php 1 patch
Spacing   +16 added lines, -16 removed lines patch added patch discarded remove patch
@@ -43,13 +43,13 @@  discard block
 block discarded – undo
43 43
      */
44 44
     public static function bootTaggable()
45 45
     {
46
-        if(static::untagOnDelete()) {
46
+        if (static::untagOnDelete()) {
47 47
             static::deleting(function($model) {
48 48
                 $model->untag();
49 49
             });
50 50
         }
51 51
 
52
-        static::saved(function ($model) {
52
+        static::saved(function($model) {
53 53
             $model->autoTagPostSave();
54 54
         });
55 55
     }
@@ -75,7 +75,7 @@  discard block
 block discarded – undo
75 75
      */
76 76
     public function getTagsAttribute()
77 77
     {
78
-        return $this->tagged->map(function(Tagged $item){
78
+        return $this->tagged->map(function(Tagged $item) {
79 79
             return $item->tag;
80 80
         });
81 81
     }
@@ -97,7 +97,7 @@  discard block
 block discarded – undo
97 97
     {
98 98
         $tagNames = TaggingUtility::makeTagArray($tagNames);
99 99
 
100
-        foreach($tagNames as $tagName) {
100
+        foreach ($tagNames as $tagName) {
101 101
             $this->addSingleTag($tagName);
102 102
         }
103 103
     }
@@ -119,7 +119,7 @@  discard block
 block discarded – undo
119 119
      */
120 120
     public function tagNames(): array
121 121
     {
122
-        return $this->tagged->map(function($item){
122
+        return $this->tagged->map(function($item) {
123 123
             return $item->tag_name;
124 124
         })->toArray();
125 125
     }
@@ -131,7 +131,7 @@  discard block
 block discarded – undo
131 131
      */
132 132
     public function tagSlugs(): array
133 133
     {
134
-        return $this->tagged->map(function($item){
134
+        return $this->tagged->map(function($item) {
135 135
             return $item->tag_slug;
136 136
         })->toArray();
137 137
     }
@@ -143,17 +143,17 @@  discard block
 block discarded – undo
143 143
      */
144 144
     public function untag($tagNames = null)
145 145
     {
146
-        if(is_null($tagNames)) {
146
+        if (is_null($tagNames)) {
147 147
             $tagNames = $this->tagNames();
148 148
         }
149 149
 
150 150
         $tagNames = TaggingUtility::makeTagArray($tagNames);
151 151
 
152
-        foreach($tagNames as $tagName) {
152
+        foreach ($tagNames as $tagName) {
153 153
             $this->removeSingleTag($tagName);
154 154
         }
155 155
 
156
-        if(static::shouldDeleteUnused()) {
156
+        if (static::shouldDeleteUnused()) {
157 157
             TaggingUtility::deleteUnusedTags();
158 158
         }
159 159
     }
@@ -173,7 +173,7 @@  discard block
 block discarded – undo
173 173
 
174 174
         $this->untag($deletions);
175 175
 
176
-        foreach($additions as $tagName) {
176
+        foreach ($additions as $tagName) {
177 177
             $this->addSingleTag($tagName);
178 178
         }
179 179
     }
@@ -188,7 +188,7 @@  discard block
 block discarded – undo
188 188
      */
189 189
     public function scopeWithAllTags(Builder $query, $tagNames): Builder
190 190
     {
191
-        if(!is_array($tagNames)) {
191
+        if (!is_array($tagNames)) {
192 192
             $tagNames = func_get_args();
193 193
             array_shift($tagNames);
194 194
         }
@@ -197,7 +197,7 @@  discard block
 block discarded – undo
197 197
 
198 198
         $className = $query->getModel()->getMorphClass();
199 199
 
200
-        foreach($tagNames as $tagSlug) {
200
+        foreach ($tagNames as $tagSlug) {
201 201
 
202 202
             $model = TaggingUtility::taggedModelString();
203 203
 
@@ -253,14 +253,14 @@  discard block
 block discarded – undo
253 253
     {
254 254
         $tagName = trim($tagName);
255 255
 
256
-        if(strlen($tagName) == 0) {
256
+        if (strlen($tagName) == 0) {
257 257
             return;
258 258
         }
259 259
 
260 260
         $tagSlug = TaggingUtility::normalize($tagName);
261 261
 
262 262
         $previousCount = $this->tagged()->where('tag_slug', '=', $tagSlug)->take(1)->count();
263
-        if($previousCount >= 1) { return; }
263
+        if ($previousCount >= 1) { return; }
264 264
 
265 265
         $model = TaggingUtility::taggedModelString();
266 266
 
@@ -289,7 +289,7 @@  discard block
 block discarded – undo
289 289
 
290 290
         $tagSlug = TaggingUtility::normalize($tagName);
291 291
 
292
-        if($count = $this->tagged()->where('tag_slug', '=', $tagSlug)->delete()) {
292
+        if ($count = $this->tagged()->where('tag_slug', '=', $tagSlug)->delete()) {
293 293
             TaggingUtility::decrementCount($tagName, $tagSlug, $count);
294 294
         }
295 295
 
@@ -383,7 +383,7 @@  discard block
 block discarded – undo
383 383
 
384 384
     private function assembleTagsForScoping($query, $tagNames)
385 385
     {
386
-        if(!is_array($tagNames)) {
386
+        if (!is_array($tagNames)) {
387 387
             $tagNames = func_get_args();
388 388
             array_shift($tagNames);
389 389
         }
Please login to merge, or discard this patch.
migrations/2020_03_13_083515_add_description_to_tags_table.php 1 patch
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -7,7 +7,7 @@  discard block
 block discarded – undo
7 7
 
8 8
     public function up()
9 9
     {
10
-        Schema::table('tagging_tags', function ($table) {
10
+        Schema::table('tagging_tags', function($table) {
11 11
             $table->text('description')->nullable();
12 12
         });
13 13
 
@@ -16,7 +16,7 @@  discard block
 block discarded – undo
16 16
 
17 17
     public function down()
18 18
     {
19
-        Schema::table('tagging_tags', function ($table) {
19
+        Schema::table('tagging_tags', function($table) {
20 20
             $table->dropColumn('description');
21 21
         });
22 22
     }
Please login to merge, or discard this patch.
src/TaggingUtility.php 2 patches
Indentation   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -162,7 +162,7 @@
 block discarded – undo
162 162
                 'ỹ' => 'y', 'Ỹ' => 'Y', 'ỵ' => 'y', 'Ỵ' => 'Y',
163 163
             
164 164
                 //Kurdish
165
-		'ا' => 'a', 'ب' => 'b', 'ج' => 'c', 'د' => 'd', 'ێ' => 'e', 'ف' => 'f', 'گ' => 'g', 'ژ' => 'j',
165
+        'ا' => 'a', 'ب' => 'b', 'ج' => 'c', 'د' => 'd', 'ێ' => 'e', 'ف' => 'f', 'گ' => 'g', 'ژ' => 'j',
166 166
                 'ک' => 'k', 'ل' => 'l', 'م' => 'm', 'ن' => 'n', 'ۆ' => 'o', 'پ' => 'p', 'ق' => 'q', 'ر' => 'r',
167 167
                 'س' => 's', 'ت' => 't', 'ڤ' => 'v','وو' => 'u', 'و' => 'w', 'خ' => 'x', 'ی' => 'y', 'ز' => 'z',
168 168
                 'ڕ' => 'rr', 'ە' => 'e', 'ح' => 'hh', 'ع' => '', 'ش' => 'sh', 'غ' => 'gh', 'ك' => 'k', 'ڵ' => 'll',
Please login to merge, or discard this patch.
Spacing   +14 added lines, -14 removed lines patch added patch discarded remove patch
@@ -20,13 +20,13 @@  discard block
 block discarded – undo
20 20
      */
21 21
     public static function makeTagArray($tagNames)
22 22
     {
23
-        if(is_array($tagNames) && count($tagNames) == 1) {
23
+        if (is_array($tagNames) && count($tagNames) == 1) {
24 24
             $tagNames = reset($tagNames);
25 25
         }
26 26
 
27
-        if(is_string($tagNames)) {
27
+        if (is_string($tagNames)) {
28 28
             $tagNames = explode(',', $tagNames);
29
-        } elseif(!is_array($tagNames)) {
29
+        } elseif (!is_array($tagNames)) {
30 30
             $tagNames = array(null);
31 31
         }
32 32
 
@@ -47,7 +47,7 @@  discard block
 block discarded – undo
47 47
     {
48 48
         $normalizer = config('tagging.normalizer');
49 49
 
50
-        if(is_string($normalizer) && Str::contains($normalizer, 'Conner\Tagging\Util')) {
50
+        if (is_string($normalizer) && Str::contains($normalizer, 'Conner\Tagging\Util')) {
51 51
             $normalizer = '\Conner\Tagging\TaggingUtility::slug';
52 52
         }
53 53
 
@@ -69,7 +69,7 @@  discard block
 block discarded – undo
69 69
     public static function slug($str)
70 70
     {
71 71
         // Make sure string is in UTF-8 and strip invalid UTF-8 characters
72
-        $str = mb_convert_encoding((string)$str, 'UTF-8');
72
+        $str = mb_convert_encoding((string) $str, 'UTF-8');
73 73
 
74 74
         $options = [
75 75
             'delimiter' => config('tagging.delimiter', '-'),
@@ -147,11 +147,11 @@  discard block
 block discarded – undo
147 147
                 'Ă' => 'A', 'ă' => 'a', 'Ș' => 'S', 'ș' => 's', 'Ț' => 'T', 'ț' => 't',
148 148
 
149 149
                 //Vietnamese
150
-                'ả' => 'a', 'Ả' => 'A','ạ' => 'a', 'Ạ' => 'A', 'ắ' => 'a', 'Ắ' => 'A', 'ằ' => 'a', 'Ằ' => 'A',
150
+                'ả' => 'a', 'Ả' => 'A', 'ạ' => 'a', 'Ạ' => 'A', 'ắ' => 'a', 'Ắ' => 'A', 'ằ' => 'a', 'Ằ' => 'A',
151 151
                 'ẳ' => 'a', 'Ẳ' => 'A', 'ẵ' => 'a', 'Ẵ' => 'A', 'ặ' => 'a', 'Ặ' => 'A', 'ẩ' => 'a', 'Ẩ' => 'A',
152 152
                 'Ấ' => 'A', 'ấ' => 'a', 'Ầ' => 'A', 'ầ' => 'a', 'Ơ' => 'O', 'ơ' => 'o', 'Đ' => 'D', 'đ' => 'd',
153 153
                 'ẫ' => 'a', 'Ẫ' => 'A', 'ậ' => 'a', 'Ậ' => 'A', 'ẻ' => 'e', 'Ẻ' => 'E', 'ẽ' => 'e', 'Ẽ' => 'E',
154
-                'ẹ' => 'e', 'Ẹ' => 'E', 'ế' => 'e', 'Ế' => 'E', 'ề' => 'e', 'Ề' => 'E',  'ể' => 'e', 'Ể' => 'E',
154
+                'ẹ' => 'e', 'Ẹ' => 'E', 'ế' => 'e', 'Ế' => 'E', 'ề' => 'e', 'Ề' => 'E', 'ể' => 'e', 'Ể' => 'E',
155 155
                 'ễ' => 'e', 'Ễ' => 'E', 'ệ' => 'e', 'Ệ' => 'E', 'ỉ' => 'i', 'Ỉ' => 'I', 'ĩ' => 'i', 'Ĩ' => 'I',
156 156
                 'ị' => 'i', 'Ị' => 'I', 'ỏ' => 'o', 'Ỏ' => 'O', 'ọ' => 'o', 'Ọ' => 'O', 'ố' => 'o', 'Ố' => 'O',
157 157
                 'ồ' => 'o', 'Ồ' => 'O', 'ổ' => 'o', 'Ổ' => 'O', 'ỗ' => 'o', 'Ỗ' => 'O', 'ộ' => 'o', 'Ộ' => 'O',
@@ -164,7 +164,7 @@  discard block
 block discarded – undo
164 164
                 //Kurdish
165 165
 		'ا' => 'a', 'ب' => 'b', 'ج' => 'c', 'د' => 'd', 'ێ' => 'e', 'ف' => 'f', 'گ' => 'g', 'ژ' => 'j',
166 166
                 'ک' => 'k', 'ل' => 'l', 'م' => 'm', 'ن' => 'n', 'ۆ' => 'o', 'پ' => 'p', 'ق' => 'q', 'ر' => 'r',
167
-                'س' => 's', 'ت' => 't', 'ڤ' => 'v','وو' => 'u', 'و' => 'w', 'خ' => 'x', 'ی' => 'y', 'ز' => 'z',
167
+                'س' => 's', 'ت' => 't', 'ڤ' => 'v', 'وو' => 'u', 'و' => 'w', 'خ' => 'x', 'ی' => 'y', 'ز' => 'z',
168 168
                 'ڕ' => 'rr', 'ە' => 'e', 'ح' => 'hh', 'ع' => '', 'ش' => 'sh', 'غ' => 'gh', 'ك' => 'k', 'ڵ' => 'll',
169 169
                 'چ' => 'ch', 'ھ' => 'h', "ئ" => '', 'ه' => 'e', 'ه' => 'h', 'ص' => 's', 'ي' => 'y', 'ة' => 'e',
170 170
                 'ط' => 't', 'ذ' => 'z', 'ؤ' => 'u', 'ظ' => 'dh', 'ض' => 'dh', 'ث' => 's', 'أ' => 'a', 'إ' => 'i',
@@ -182,7 +182,7 @@  discard block
 block discarded – undo
182 182
         $str = preg_replace('/[^\p{L}\p{Nd}]+/u', $options['delimiter'], $str);
183 183
 
184 184
         // Remove duplicate delimiters
185
-        $str = preg_replace('/(' . preg_quote($options['delimiter'], '/') . '){2,}/', '$1', $str);
185
+        $str = preg_replace('/('.preg_quote($options['delimiter'], '/').'){2,}/', '$1', $str);
186 186
 
187 187
         // Truncate slug to max. characters
188 188
         $str = mb_substr($str, 0, ($options['limit'] ? $options['limit'] : mb_strlen($str, 'UTF-8')), 'UTF-8');
@@ -203,12 +203,12 @@  discard block
 block discarded – undo
203 203
      */
204 204
     public static function incrementCount($tagString, $tagSlug, $count)
205 205
     {
206
-        if($count <= 0) { return; }
206
+        if ($count <= 0) { return; }
207 207
         $model = static::tagModelString();
208 208
 
209 209
         $tag = $model::where('slug', '=', $tagSlug)->first();
210 210
 
211
-        if(!$tag) {
211
+        if (!$tag) {
212 212
             $tag = new $model;
213 213
             $tag->name = $tagString;
214 214
             $tag->slug = $tagSlug;
@@ -228,14 +228,14 @@  discard block
 block discarded – undo
228 228
      */
229 229
     public static function decrementCount($tagString, $tagSlug, $count)
230 230
     {
231
-        if($count <= 0) { return; }
231
+        if ($count <= 0) { return; }
232 232
         $model = static::tagModelString();
233 233
 
234 234
         $tag = $model::where('slug', '=', $tagSlug)->first();
235 235
 
236
-        if($tag) {
236
+        if ($tag) {
237 237
             $tag->count = $tag->count - $count;
238
-            if($tag->count < 0) {
238
+            if ($tag->count < 0) {
239 239
                 $tag->count = 0;
240 240
                 \Log::warning("The '.$model.' count for `$tag->name` was a negative number. This probably means your data got corrupted. Please assess your code and report an issue if you find one.");
241 241
             }
Please login to merge, or discard this patch.