Completed
Push — laravel-5 ( 174d48...20339e )
by Robert
03:23
created
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
     }
@@ -74,7 +74,7 @@  discard block
 block discarded – undo
74 74
      */
75 75
     public function getTagsAttribute()
76 76
     {
77
-        return $this->tagged->map(function(Tagged $item){
77
+        return $this->tagged->map(function(Tagged $item) {
78 78
             return $item->tag;
79 79
         });
80 80
     }
@@ -96,7 +96,7 @@  discard block
 block discarded – undo
96 96
     {
97 97
         $tagNames = TaggingUtility::makeTagArray($tagNames);
98 98
 
99
-        foreach($tagNames as $tagName) {
99
+        foreach ($tagNames as $tagName) {
100 100
             $this->addTag($tagName);
101 101
         }
102 102
     }
@@ -108,7 +108,7 @@  discard block
 block discarded – undo
108 108
      */
109 109
     public function tagNames(): array
110 110
     {
111
-        return $this->tagged->map(function($item){
111
+        return $this->tagged->map(function($item) {
112 112
             return $item->tag_name;
113 113
         })->toArray();
114 114
     }
@@ -120,7 +120,7 @@  discard block
 block discarded – undo
120 120
      */
121 121
     public function tagSlugs(): array
122 122
     {
123
-        return $this->tagged->map(function($item){
123
+        return $this->tagged->map(function($item) {
124 124
             return $item->tag_slug;
125 125
         })->toArray();
126 126
     }
@@ -132,17 +132,17 @@  discard block
 block discarded – undo
132 132
      */
133 133
     public function untag($tagNames = null)
134 134
     {
135
-        if(is_null($tagNames)) {
135
+        if (is_null($tagNames)) {
136 136
             $tagNames = $this->tagNames();
137 137
         }
138 138
 
139 139
         $tagNames = TaggingUtility::makeTagArray($tagNames);
140 140
 
141
-        foreach($tagNames as $tagName) {
141
+        foreach ($tagNames as $tagName) {
142 142
             $this->removeSingleTag($tagName);
143 143
         }
144 144
 
145
-        if(static::shouldDeleteUnused()) {
145
+        if (static::shouldDeleteUnused()) {
146 146
             TaggingUtility::deleteUnusedTags();
147 147
         }
148 148
     }
@@ -162,7 +162,7 @@  discard block
 block discarded – undo
162 162
 
163 163
         $this->untag($deletions);
164 164
 
165
-        foreach($additions as $tagName) {
165
+        foreach ($additions as $tagName) {
166 166
             $this->addTag($tagName);
167 167
         }
168 168
     }
@@ -176,7 +176,7 @@  discard block
 block discarded – undo
176 176
      */
177 177
     public function scopeWithAllTags(Builder $query, $tagNames): Builder
178 178
     {
179
-        if(!is_array($tagNames)) {
179
+        if (!is_array($tagNames)) {
180 180
             $tagNames = func_get_args();
181 181
             array_shift($tagNames);
182 182
         }
@@ -185,7 +185,7 @@  discard block
 block discarded – undo
185 185
 
186 186
         $className = $query->getModel()->getMorphClass();
187 187
 
188
-        foreach($tagNames as $tagSlug) {
188
+        foreach ($tagNames as $tagSlug) {
189 189
             $tags = Tagged::query()
190 190
                 ->where('tag_slug', TaggingUtility::normalize($tagSlug))
191 191
                 ->where('taggable_type', $className)
@@ -236,14 +236,14 @@  discard block
 block discarded – undo
236 236
     {
237 237
         $tagName = trim($tagName);
238 238
 
239
-        if(strlen($tagName) == 0) {
239
+        if (strlen($tagName) == 0) {
240 240
             return;
241 241
         }
242 242
 
243 243
         $tagSlug = TaggingUtility::normalize($tagName);
244 244
 
245 245
         $previousCount = $this->tagged()->where('tag_slug', '=', $tagSlug)->take(1)->count();
246
-        if($previousCount >= 1) { return; }
246
+        if ($previousCount >= 1) { return; }
247 247
 
248 248
         $tagged = new Tagged([
249 249
             'tag_name' => TaggingUtility::displayize($tagName),
@@ -270,7 +270,7 @@  discard block
 block discarded – undo
270 270
 
271 271
         $tagSlug = TaggingUtility::normalize($tagName);
272 272
 
273
-        if($count = $this->tagged()->where('tag_slug', '=', $tagSlug)->delete()) {
273
+        if ($count = $this->tagged()->where('tag_slug', '=', $tagSlug)->delete()) {
274 274
             TaggingUtility::decrementCount($tagName, $tagSlug, $count);
275 275
         }
276 276
 
@@ -360,7 +360,7 @@  discard block
 block discarded – undo
360 360
 
361 361
     private function assembleTagsForScoping($query, $tagNames)
362 362
     {
363
-        if(!is_array($tagNames)) {
363
+        if (!is_array($tagNames)) {
364 364
             $tagNames = func_get_args();
365 365
             array_shift($tagNames);
366 366
         }
Please login to merge, or discard this patch.