Code Duplication    Length = 24-24 lines in 2 locations

app/Helpers/ProjectRoleHelper.php 2 locations

@@ 224-247 (lines=24) @@
221
     *
222
     * @return bool
223
     */
224
    protected function isAllowedToChangeTaskStatus($project_id, $column_id, $role)
225
    {
226
        $columnRestrictions = $this->columnRestrictionCacheDecorator->getAllByRole($project_id, $role);
227
228
        foreach ($columnRestrictions as $restriction) {
229
            if ($restriction['column_id'] == $column_id) {
230
                if ($restriction['rule'] == ColumnRestrictionModel::RULE_ALLOW_TASK_OPEN_CLOSE) {
231
                    return true;
232
                } elseif ($restriction['rule'] == ColumnRestrictionModel::RULE_BLOCK_TASK_OPEN_CLOSE) {
233
                    return false;
234
                }
235
            }
236
        }
237
238
        $projectRestrictions = $this->projectRoleRestrictionCacheDecorator->getAllByRole($project_id, $role);
239
240
        foreach ($projectRestrictions as $restriction) {
241
            if ($restriction['rule'] == ProjectRoleRestrictionModel::RULE_TASK_OPEN_CLOSE) {
242
                return false;
243
            }
244
        }
245
246
        return true;
247
    }
248
249
    /**
250
     * Check authorization for a custom project role to create a task.
@@ 258-281 (lines=24) @@
255
     *
256
     * @return bool
257
     */
258
    protected function isAllowedToCreateTask($project_id, $column_id, $role)
259
    {
260
        $columnRestrictions = $this->columnRestrictionCacheDecorator->getAllByRole($project_id, $role);
261
262
        foreach ($columnRestrictions as $restriction) {
263
            if ($restriction['column_id'] == $column_id) {
264
                if ($restriction['rule'] == ColumnRestrictionModel::RULE_ALLOW_TASK_CREATION) {
265
                    return true;
266
                } elseif ($restriction['rule'] == ColumnRestrictionModel::RULE_BLOCK_TASK_CREATION) {
267
                    return false;
268
                }
269
            }
270
        }
271
272
        $projectRestrictions = $this->projectRoleRestrictionCacheDecorator->getAllByRole($project_id, $role);
273
274
        foreach ($projectRestrictions as $restriction) {
275
            if ($restriction['rule'] == ProjectRoleRestrictionModel::RULE_TASK_CREATION) {
276
                return false;
277
            }
278
        }
279
280
        return true;
281
    }
282
283
    /**
284
     * Check if the role can move task in the given project.