Code Duplication    Length = 36-36 lines in 2 locations

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

@@ 357-392 (lines=36) @@
354
     *
355
     * @return $this
356
     */
357
    public function changeKanbanTag(Tag $newTag, Tag $oldTag)
358
    {
359
        //  skip if there is no change in status tags
360
        if ($oldTag->name === $newTag->name) {
361
            return $this;
362
        }
363
364
        // Open issue
365
        $data = ['added_tags' => [], 'removed_tags' => []];
366
367
        // Remove previous status tag
368
        $this->tags()->detach($oldTag);
369
        $data['removed_tags'][] = $oldTag->toShortArray();
370
371
        // Add new tag
372
        if (!$this->tags->contains($newTag)) {
373
            $this->tags()->attach($newTag);
374
375
            $data['added_tags'][] = $newTag->toShortArray();
376
        }
377
378
        if (!empty($data)) {
379
            // Add this change to messages queue
380
            $this->queueChangeTags($this, $data['added_tags'], $data['removed_tags'], $this->user);
381
382
            // Add to activity log for tags if changed
383
            $this->activities()->save(new User\Activity([
384
                'type_id'   => Activity::TYPE_ISSUE_TAG,
385
                'parent_id' => $this->project->id,
386
                'user_id'   => $this->user->id,
387
                'data'      => $data,
388
            ]));
389
        }
390
391
        return $this;
392
    }
393
}
394

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

@@ 144-179 (lines=36) @@
141
     *
142
     * @return $this
143
     */
144
    public function changeKanbanTag(Tag $newTag, Tag $oldTag)
145
    {
146
        //  skip if there is no change in status tags
147
        if ($oldTag->name === $newTag->name) {
148
            return $this;
149
        }
150
151
        // Open issue
152
        $data = ['added_tags' => [], 'removed_tags' => []];
153
154
        // Remove previous status tag
155
        $this->tags()->detach($oldTag);
156
        $data['removed_tags'][] = $oldTag->toShortArray();
157
158
        // Add new tag
159
        if (!$this->tags->contains($newTag)) {
160
            $this->tags()->attach($newTag);
161
162
            $data['added_tags'][] = $newTag->toShortArray();
163
        }
164
165
        if (!empty($data)) {
166
            // Add this change to messages queue
167
            $this->queueChangeTags($this, $data['added_tags'], $data['removed_tags'], $this->user);
168
169
            // Add to activity log for tags if changed
170
            $this->activities()->save(new User\Activity([
171
                'type_id'   => Activity::TYPE_ISSUE_TAG,
172
                'parent_id' => $this->project->id,
173
                'user_id'   => $this->user->id,
174
                'data'      => $data,
175
            ]));
176
        }
177
178
        return $this;
179
    }
180
181
    abstract public function activities();
182
    abstract public function queueUpdate(Project\Issue $issue, User $changeBy);