Checkbox::value()   A
last analyzed

Complexity

Conditions 3
Paths 2

Size

Total Lines 8
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 5
CRAP Score 3

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 3
eloc 4
c 1
b 0
f 0
nc 2
nop 1
dl 0
loc 8
rs 10
ccs 5
cts 5
cp 1
crap 3
1
<?php
2
3
namespace Yaro\Jarboe\Table\Fields;
4
5
use Illuminate\Http\Request;
6
use Yaro\Jarboe\Table\Fields\Traits\Inline;
7
use Yaro\Jarboe\Table\Fields\Traits\Nullable;
8
use Yaro\Jarboe\Table\Fields\Traits\Orderable;
9
10
class Checkbox 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...
11
{
12
    use Orderable;
13
    use Nullable;
14
    use Inline;
15
16 4
    public function value(Request $request)
17
    {
18 4
        $value = parent::value($request);
19 4
        if (is_null($value) && $this->isNullable()) {
20 1
            return null;
21
        }
22
23 4
        return (bool) $value;
24
    }
25
26 1
    public function getListView($model)
27
    {
28 1
        return view('jarboe::crud.fields.checkbox.list', [
29 1
            'model' => $model,
30 1
            'field' => $this,
31
        ]);
32
    }
33
34 1
    public function getEditFormView($model)
35
    {
36 1
        $template = $this->isReadonly() ? 'readonly' : 'edit';
37
38 1
        return view('jarboe::crud.fields.checkbox.'. $template, [
39 1
            'model' => $model,
40 1
            'field' => $this,
41
        ]);
42
    }
43
44 1
    public function getCreateFormView()
45
    {
46 1
        return view('jarboe::crud.fields.checkbox.create', [
47 1
            'field' => $this,
48
        ]);
49
    }
50
51 2
    public function oldOrAttribute($model, $locale = null)
52
    {
53 2
        $value = parent::oldOrAttribute($model, $locale);
54 2
        if ($value === 'true' || $value === 'false') {
55 2
            $value = $value === 'true';
56
        }
57
58 2
        return $value;
59
    }
60
}
61