Code Duplication    Length = 8-8 lines in 4 locations

components/ItemController.php 2 locations

@@ 122-129 (lines=8) @@
119
     * @param string $id
120
     * @return array
121
     */
122
    public function actionAssign($id)
123
    {
124
        $items = Yii::$app->getRequest()->post('items', []);
125
        $model = $this->findModel($id);
126
        $success = $model->addChildren($items);
127
        Yii::$app->getResponse()->format = 'json';
128
129
        return array_merge($model->getItems(), ['success' => $success]);
130
    }
131
132
    /**
@@ 151-158 (lines=8) @@
148
     * @param string $id
149
     * @return array
150
     */
151
    public function actionRemove($id)
152
    {
153
        $items = Yii::$app->getRequest()->post('items', []);
154
        $model = $this->findModel($id);
155
        $success = $model->removeChildren($items);
156
        Yii::$app->getResponse()->format = 'json';
157
158
        return array_merge($model->getItems(), ['success' => $success]);
159
    }
160
161
    /**

controllers/AssignmentController.php 2 locations

@@ 102-109 (lines=8) @@
99
     * @param string $id
100
     * @return array
101
     */
102
    public function actionAssign($id)
103
    {
104
        $items = Yii::$app->getRequest()->post('items', []);
105
        $model = new Assignment($id);
106
        $success = $model->assign($items);
107
        Yii::$app->getResponse()->format = 'json';
108
        return array_merge($model->getItems(), ['success' => $success]);
109
    }
110
111
    /**
112
     * Assign items
@@ 116-123 (lines=8) @@
113
     * @param string $id
114
     * @return array
115
     */
116
    public function actionRevoke($id)
117
    {
118
        $items = Yii::$app->getRequest()->post('items', []);
119
        $model = new Assignment($id);
120
        $success = $model->revoke($items);
121
        Yii::$app->getResponse()->format = 'json';
122
        return array_merge($model->getItems(), ['success' => $success]);
123
    }
124
125
    /**
126
     * Finds the Assignment model based on its primary key value.