Code Duplication    Length = 31-31 lines in 2 locations

app/Repository/Project/Issue/UpdaterRepository.php 1 location

@@ 297-327 (lines=31) @@
294
        $tags = (new Tag())->whereIn('id', $tagIds)->get();
295
296
        $removedTags = [];
297
        if (null === $currentTags) {
298
            // Add the following tags except for open status
299
            $addedTags = $tags
300
                ->map(function (Tag $tag) {
301
                    return $tag->toShortArray();
302
                })
303
                ->toArray();
304
        } else {
305
            // Tags remove from the issue
306
            $removedTags = $currentTags
307
                ->diff($tags)
308
                ->map(function (Tag $tag) {
309
                    return $tag->toShortArray();
310
                })
311
                ->toArray();
312
313
            // Check if we are adding new tags
314
            $addedTags = $tags
315
                ->filter(function (Tag $tag) use ($currentTags) {
316
                    return $currentTags->where('id', $tag->id)->count() === 0;
317
                })
318
                ->map(function (Tag $tag) {
319
                    return $tag->toShortArray();
320
                })
321
                ->toArray();
322
323
            // No new tags to add or remove
324
            if (empty($removedTags) && empty($addedTags)) {
325
                return true;
326
            }
327
        }
328
329
        // Save relation
330
        $this->tags()->sync($tags->pluck('id')->all());

app/Repository/Traits/Project/Issue/CrudTagTrait.php 1 location

@@ 84-114 (lines=31) @@
81
        $tags = (new Tag())->whereIn('id', $tagIds)->get();
82
83
        $removedTags = [];
84
        if (null === $currentTags) {
85
            // Add the following tags except for open status
86
            $addedTags = $tags
87
                ->map(function (Tag $tag) {
88
                    return $tag->toShortArray();
89
                })
90
                ->toArray();
91
        } else {
92
            // Tags remove from the issue
93
            $removedTags = $currentTags
94
                ->diff($tags)
95
                ->map(function (Tag $tag) {
96
                    return $tag->toShortArray();
97
                })
98
                ->toArray();
99
100
            // Check if we are adding new tags
101
            $addedTags = $tags
102
                ->filter(function (Tag $tag) use ($currentTags) {
103
                    return $currentTags->where('id', $tag->id)->count() === 0;
104
                })
105
                ->map(function (Tag $tag) {
106
                    return $tag->toShortArray();
107
                })
108
                ->toArray();
109
110
            // No new tags to add or remove
111
            if (empty($removedTags) && empty($addedTags)) {
112
                return true;
113
            }
114
        }
115
116
        // Save relation
117
        $this->tags()->sync($tags->pluck('id')->all());