Number::value()   A
last analyzed

Complexity

Conditions 5
Paths 3

Size

Total Lines 8
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 5
CRAP Score 5

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 5
eloc 4
c 1
b 0
f 0
nc 3
nop 1
dl 0
loc 8
rs 9.6111
ccs 5
cts 5
cp 1
crap 5
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\MinMaxStep;
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
14
class Number extends AbstractField
0 ignored issues
show
Bug introduced by
The type Yaro\Jarboe\Table\Fields\AbstractField was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
15
{
16
    use Orderable;
17
    use Nullable;
18
    use Tooltip;
19
    use Clipboard;
20
    use Inline;
21
    use Placeholder;
22
    use MinMaxStep;
23
24 1
    public function value(Request $request)
25
    {
26 1
        $value = $request->get($this->name());
27 1
        if (!$value && $value !== "0" && $this->isNullable()) {
28 1
            return null;
29
        }
30
31 1
        return is_null($value) ? 0 : (float) $value;
32
    }
33
34 1
    public function getListView($model)
35
    {
36 1
        return view('jarboe::crud.fields.number.list', [
37 1
            'model' => $model,
38 1
            'field' => $this,
39
        ]);
40
    }
41
42 1
    public function getEditFormView($model)
43
    {
44 1
        $template = $this->isReadonly() ? 'readonly' : 'edit';
45
46 1
        return view('jarboe::crud.fields.number.'. $template, [
47 1
            'model' => $model,
48 1
            'field' => $this,
49
        ]);
50
    }
51
52 1
    public function getCreateFormView()
53
    {
54 1
        return view('jarboe::crud.fields.number.create', [
55 1
            'field' => $this,
56
        ]);
57
    }
58
}
59