Completed
Pull Request — master (#14)
by
unknown
15:13 queued 07:44
created

Textarea::getListValue()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 12

Duplication

Lines 12
Ratio 100 %

Code Coverage

Tests 7
CRAP Score 2

Importance

Changes 0
Metric Value
dl 12
loc 12
ccs 7
cts 7
cp 1
rs 9.8666
c 0
b 0
f 0
cc 2
nc 2
nop 1
crap 2
1
<?php
2
3
namespace Yaro\Jarboe\Table\Fields;
4
5
use Illuminate\Http\Request;
6
use Yaro\Jarboe\Table\Fields\Traits\Clipboard;
7
use Yaro\Jarboe\Table\Fields\Traits\Inline;
8
use Yaro\Jarboe\Table\Fields\Traits\Maxlength;
9
use Yaro\Jarboe\Table\Fields\Traits\Nullable;
10
use Yaro\Jarboe\Table\Fields\Traits\Orderable;
11
use Yaro\Jarboe\Table\Fields\Traits\Placeholder;
12
use Yaro\Jarboe\Table\Fields\Traits\Tooltip;
13
use Yaro\Jarboe\Table\Fields\Traits\Translatable;
14
15
class Textarea extends AbstractField
16
{
17
    use Orderable;
18
    use Nullable;
19
    use Tooltip;
20
    use Clipboard;
21
    use Inline;
22
    use Translatable;
23
    use Placeholder;
24
    use Maxlength;
25
26
    protected $rows = 3;
27
    protected $expandable = false;
28
    protected $resizable = false;
29
30 1
    public function rows(int $rows)
31
    {
32 1
        $this->rows = $rows;
33
34 1
        return $this;
35
    }
36
37 2
    public function getRowsNum()
38
    {
39 2
        return $this->rows;
40
    }
41
42 1
    public function expandable(bool $expandable = true)
43
    {
44 1
        $this->expandable = $expandable;
45
46 1
        return $this;
47
    }
48
49 2
    public function isExpandable()
50
    {
51 2
        return $this->expandable;
52
    }
53
54 1
    public function resizable(bool $resizable = true)
55
    {
56 1
        $this->resizable = $resizable;
57
58 1
        return $this;
59
    }
60
61 2
    public function isResizable()
62
    {
63 2
        return $this->resizable;
64
    }
65
66 3 View Code Duplication
    public function value(Request $request)
67
    {
68 3
        $value = parent::value($request);
69 3
        if (is_null($value) && $this->isNullable()) {
70 1
            return null;
71
        }
72
73 3
        return is_array($value) ? $value : (string) $value;
74
    }
75
76 2 View Code Duplication
    public function getListView($model)
77
    {
78 2
        $template = 'list';
79 2
        if ($this->isTranslatable()) {
80 1
            $template .= '_translatable';
81
        }
82
83 2
        return view('jarboe::crud.fields.textarea.'. $template, [
84 2
            'model' => $model,
85 2
            'field' => $this,
86
        ]);
87
    }
88
89 1
    public function getEditFormView($model)
90
    {
91 1
        $template = $this->isReadonly() ? 'readonly' : 'edit';
92
93 1
        return view('jarboe::crud.fields.textarea.'. $template, [
94 1
            'model' => $model,
95 1
            'field' => $this,
96
        ]);
97
    }
98
99 1
    public function getCreateFormView()
100
    {
101 1
        return view('jarboe::crud.fields.textarea.create', [
102 1
            'field' => $this,
103
        ]);
104
    }
105
}
106