Hidden::hideList()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 5
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 3
CRAP Score 1

Importance

Changes 0
Metric Value
cc 1
eloc 2
c 0
b 0
f 0
nc 1
nop 1
dl 0
loc 5
rs 10
ccs 3
cts 3
cp 1
crap 1
1
<?php
2
3
namespace Yaro\Jarboe\Table\Fields\Traits;
4
5
trait Hidden
6
{
7
    protected $hidden = [
8
        'list'   => false,
9
        'edit'   => false,
10
        'create' => false,
11
    ];
12
13 13
    public function hide(bool $edit = false, bool $create = false, bool $list = false)
14
    {
15 13
        $this->hidden = [
16 13
            'list'   => $list,
17 13
            'edit'   => $edit,
18 13
            'create' => $create,
19
        ];
20
21 13
        return $this;
22
    }
23
24 16
    public function hideList(bool $hide = false)
25
    {
26 16
        $this->hidden['list'] = $hide;
27
28 16
        return $this;
29
    }
30
31 16
    public function hideEdit(bool $hide = false)
32
    {
33 16
        $this->hidden['edit'] = $hide;
34
35 16
        return $this;
36
    }
37
38 16
    public function hideCreate(bool $hide = false)
39
    {
40 16
        $this->hidden['create'] = $hide;
41
42 16
        return $this;
43
    }
44
45 38
    public function hidden(string $type)
46
    {
47 38
        if (!array_key_exists($type, $this->hidden)) {
48 17
            throw new \RuntimeException(sprintf("Wrong type [%s] for field's hidden attribute", $type));
49
        }
50
51 21
        return $this->hidden[$type];
52
    }
53
}
54