Code Duplication    Length = 5-5 lines in 4 locations

backend/controllers/TermRelationshipController.php 4 locations

@@ 71-75 (lines=5) @@
68
        if (Yii::$app->request->post('action') === 'addItem') {
69
            $model = new TermRelationship();
70
            $model->load(Yii::$app->request->post());
71
            if ($model->save()) {
72
                if ($term = $this->findTerm($model->term_id)) {
73
                    $term->updateAttributes(['count' => ++$term->count]);
74
                }
75
            }
76
        } elseif (Yii::$app->request->post('action') === 'remItem'
77
            && $termRelationship = Yii::$app->request->post('TermRelationship')
78
        ) {
@@ 80-84 (lines=5) @@
77
            && $termRelationship = Yii::$app->request->post('TermRelationship')
78
        ) {
79
            $model = $this->findModel($termRelationship['post_id'], $termRelationship['term_id']);
80
            if ($model->delete()) {
81
                if ($term = $this->findTerm($model->term_id)) {
82
                    $term->updateAttributes(['count' => --$term->count]);
83
                }
84
            }
85
        }
86
    }
87
@@ 95-99 (lines=5) @@
92
    {
93
        $model = new TermRelationship();
94
95
        if ($model->load(Yii::$app->request->post()) && $model->save()) {
96
            if ($term = $this->findTerm($model->term_id)) {
97
                $term->updateAttributes(['count' => ++$term->count]);
98
            }
99
        }
100
    }
101
102
    /**
@@ 113-117 (lines=5) @@
110
    {
111
        if ($termRelationship = Yii::$app->request->post('TermRelationship')) {
112
            $model = $this->findModel($termRelationship['post_id'], $termRelationship['term_id']);
113
            if ($model->delete()) {
114
                if ($term = $this->findTerm($model->term_id)) {
115
                    $term->updateAttributes(['count' => --$term->count]);
116
                }
117
            }
118
        }
119
    }
120