Completed
Push — laravel-5 ( 20339e...2e6014 )
by Robert
05:18
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
 
190 190
             $model = TaggingUtility::taggedModelString();
191 191
 
@@ -239,14 +239,14 @@  discard block
 block discarded – undo
239 239
     {
240 240
         $tagName = trim($tagName);
241 241
 
242
-        if(strlen($tagName) == 0) {
242
+        if (strlen($tagName) == 0) {
243 243
             return;
244 244
         }
245 245
 
246 246
         $tagSlug = TaggingUtility::normalize($tagName);
247 247
 
248 248
         $previousCount = $this->tagged()->where('tag_slug', '=', $tagSlug)->take(1)->count();
249
-        if($previousCount >= 1) { return; }
249
+        if ($previousCount >= 1) { return; }
250 250
 
251 251
         $model = TaggingUtility::taggedModelString();
252 252
 
@@ -275,7 +275,7 @@  discard block
 block discarded – undo
275 275
 
276 276
         $tagSlug = TaggingUtility::normalize($tagName);
277 277
 
278
-        if($count = $this->tagged()->where('tag_slug', '=', $tagSlug)->delete()) {
278
+        if ($count = $this->tagged()->where('tag_slug', '=', $tagSlug)->delete()) {
279 279
             TaggingUtility::decrementCount($tagName, $tagSlug, $count);
280 280
         }
281 281
 
@@ -369,7 +369,7 @@  discard block
 block discarded – undo
369 369
 
370 370
     private function assembleTagsForScoping($query, $tagNames)
371 371
     {
372
-        if(!is_array($tagNames)) {
372
+        if (!is_array($tagNames)) {
373 373
             $tagNames = func_get_args();
374 374
             array_shift($tagNames);
375 375
         }
Please login to merge, or discard this patch.