ConfigStatusController   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 30
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 2

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 3
c 1
b 0
f 0
lcom 0
cbo 2
dl 0
loc 30
rs 10

1 Method

Rating   Name   Duplication   Size   Complexity  
A updatePosition() 0 20 3
1
<?php
2
3
namespace GitScrum\Http\Controllers;
4
5
use Illuminate\Http\Request;
6
use GitScrum\Models\ConfigStatus;
7
8
class ConfigStatusController extends Controller
9
{
10
    /**
11
     * Update the specified resource in storage.
12
     *
13
     * @param \Illuminate\Http\Request $request
14
     *
15
     * @return \Illuminate\Http\Response
0 ignored issues
show
Documentation introduced by
Should the return type not be \Illuminate\Http\JsonResponse?

This check compares the return type specified in the @return annotation of a function or method doc comment with the types returned by the function and raises an issue if they mismatch.

Loading history...
16
     */
17
    public function updatePosition(Request $request)
18
    {
19
        try {
20
            $position = 1;
21
            foreach ($request->columns as $id) {
22
                $configStatus = ConfigStatus::find($id);
23
                $configStatus->position = $position;
24
                $configStatus->save();
25
                ++$position;
26
            }
27
28
            return response()->json([
29
                'success' => true,
30
            ]);
31
        } catch (\Exception $e) {
32
            return response()->json([
33
                'success' => false,
34
            ]);
35
        }
36
    }
37
}
38