Completed
Push — master ( 814073...4a1646 )
by Yaro
10:23 queued 02:16
created

IconPicker   A

Complexity

Total Complexity 5

Size/Duplication

Total Lines 35
Duplicated Lines 25.71 %

Coupling/Cohesion

Components 0
Dependencies 2

Test Coverage

Coverage 85.71%

Importance

Changes 0
Metric Value
wmc 5
lcom 0
cbo 2
dl 9
loc 35
ccs 12
cts 14
cp 0.8571
rs 10
c 0
b 0
f 0

4 Methods

Rating   Name   Duplication   Size   Complexity  
A value() 0 4 1
A getListValue() 0 7 1
A getEditFormValue() 9 9 2
A getCreateFormValue() 0 6 1

How to fix   Duplicated Code   

Duplicated Code

Duplicate code is one of the most pungent code smells. A rule that is often used is to re-structure code once it is duplicated in three or more places.

Common duplication problems, and corresponding solutions are:

1
<?php
2
3
namespace Yaro\Jarboe\Table\Fields;
4
5
use Illuminate\Http\Request;
6
use Yaro\Jarboe\Table\Fields\Traits\Nullable;
7
use Yaro\Jarboe\Table\Fields\Traits\Orderable;
8
9
class IconPicker extends AbstractField
10
{
11
    use Orderable;
12
13
    public function value(Request $request)
14
    {
15
        return (string) parent::value($request);
16
    }
17
18 1
    public function getListValue($model)
19
    {
20 1
        return view('jarboe::crud.fields.icon-picker.list', [
21 1
            'model' => $model,
22 1
            'field' => $this,
23
        ]);
24
    }
25
26 1 View Code Duplication
    public function getEditFormValue($model)
27
    {
28 1
        $template = $this->isReadonly() ? 'readonly' : 'edit';
29
30 1
        return view('jarboe::crud.fields.icon-picker.'. $template, [
31 1
            'model' => $model,
32 1
            'field' => $this,
33
        ]);
34
    }
35
36 1
    public function getCreateFormValue()
37
    {
38 1
        return view('jarboe::crud.fields.icon-picker.create', [
39 1
            'field' => $this,
40
        ]);
41
    }
42
43
}