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

Markdown   A

Complexity

Total Complexity 5

Size/Duplication

Total Lines 34
Duplicated Lines 26.47 %

Coupling/Cohesion

Components 0
Dependencies 2

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
wmc 5
lcom 0
cbo 2
dl 9
loc 34
ccs 14
cts 14
cp 1
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\Orderable;
7
8
class Markdown extends AbstractField
9
{
10
    use Orderable;
11
12 1
    public function value(Request $request)
13
    {
14 1
        return (string) parent::value($request);
15
    }
16
17 1
    public function getListValue($model)
18
    {
19 1
        return view('jarboe::crud.fields.markdown.list', [
20 1
            'model' => $model,
21 1
            'field' => $this,
22
        ]);
23
    }
24
25 1 View Code Duplication
    public function getEditFormValue($model)
26
    {
27 1
        $template = $this->isReadonly() ? 'readonly' : 'edit';
28
29 1
        return view('jarboe::crud.fields.markdown.'. $template, [
30 1
            'model' => $model,
31 1
            'field' => $this,
32
        ]);
33
    }
34
35 1
    public function getCreateFormValue()
36
    {
37 1
        return view('jarboe::crud.fields.markdown.create', [
38 1
            'field' => $this,
39
        ]);
40
    }
41
}
42