Completed
Push — master ( d9e017...cb8e5c )
by wen
04:31
created

UploadController   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 15
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 2

Importance

Changes 0
Metric Value
wmc 2
c 0
b 0
f 0
lcom 0
cbo 2
dl 0
loc 15
rs 10

1 Method

Rating   Name   Duplication   Size   Complexity  
A formElement() 0 12 2
1
<?php
2
3
namespace Sco\Admin\Http\Controllers;
4
5
use App\Http\Controllers\Controller;
6
use Illuminate\Http\Request;
7
use Sco\Admin\Contracts\ComponentInterface;
8
9
class UploadController extends Controller
10
{
11
    public function formElement(Request $request, ComponentInterface $component, $field, $id = null)
12
    {
13
        if (is_null($id)) {
14
            $form = $component->fireCreate();
15
        } else {
16
            $form = $component->fireEdit($id);
17
        }
18
19
        $element = $form->getElement($field);
0 ignored issues
show
Bug introduced by
The method getElement() does not exist on Sco\Admin\Contracts\Form\FormInterface. Did you maybe mean getElements()?

This check marks calls to methods that do not seem to exist on an object.

This is most likely the result of a method being renamed without all references to it being renamed likewise.

Loading history...
Unused Code introduced by
$element is not used, you could remove the assignment.

This check looks for variable assignements that are either overwritten by other assignments or where the variable is not used subsequently.

$myVar = 'Value';
$higher = false;

if (rand(1, 6) > 3) {
    $higher = true;
} else {
    $higher = false;
}

Both the $myVar assignment in line 1 and the $higher assignment in line 2 are dead. The first because $myVar is never used and the second because $higher is always overwritten for every possible time line.

Loading history...
20
21
        return response()->json(['message' => 'ok', 'id' => time()]);
22
    }
23
}
24