Completed
Push — master ( 72d72a...bb8091 )
by Yaro
06:09
created

Hidden::hidden()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 8

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 4
CRAP Score 2

Importance

Changes 0
Metric Value
dl 0
loc 8
rs 10
c 0
b 0
f 0
ccs 4
cts 4
cp 1
cc 2
nc 2
nop 1
crap 2
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 15
    public function hideList(bool $hide = false)
25
    {
26 15
        $this->hidden['list'] = $hide;
27
28 15
        return $this;
29
    }
30
31 15
    public function hideEdit(bool $hide = false)
32
    {
33 15
        $this->hidden['edit'] = $hide;
34
35 15
        return $this;
36
    }
37
38 15
    public function hideCreate(bool $hide = false)
39
    {
40 15
        $this->hidden['create'] = $hide;
41
42 15
        return $this;
43
    }
44
45 34
    public function hidden(string $type)
0 ignored issues
show
Documentation introduced by
The return type could not be reliably inferred; please add a @return annotation.

Our type inference engine in quite powerful, but sometimes the code does not provide enough clues to go by. In these cases we request you to add a @return annotation as described here.

Loading history...
46
    {
47 34
        if (!array_key_exists($type, $this->hidden)) {
48 16
            throw new \RuntimeException(sprintf("Wrong type [%s] for field's hidden attribute", $type));
49
        }
50
51 18
        return $this->hidden[$type];
52
    }
53
}
54