Passed
Push — master ( 09ca5f...5335b9 )
by Iman
09:02 queued 04:49
created

CbFormLoader::checkHideForm()   A

Complexity

Conditions 4
Paths 4

Size

Total Lines 8
Code Lines 5

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 4
eloc 5
nc 4
nop 0
dl 0
loc 8
rs 9.2
c 0
b 0
f 0
1
<?php
2
3
namespace crocodicstudio\crudbooster\controllers\CBController;
4
5
trait CbFormLoader
6
{
7
8
    public $hide_form = [];
9
10
    public $button_cancel = true;
11
12
    public $button_save = true;
13
14
    public $button_add = true;
15
16
    public $button_addmore = true;
17
18
    public $show_addaction = true;
19
20
    protected function cbFormLoader()
21
    {
22
        $this->data['button_add'] = $this->button_add;
0 ignored issues
show
Bug Best Practice introduced by
The property data does not exist. Although not strictly required by PHP, it is generally a best practice to declare properties explicitly.
Loading history...
23
        $this->data['button_addmore'] = $this->button_addmore;
24
        $this->data['button_cancel'] = $this->button_cancel;
25
        $this->data['button_save'] = $this->button_save;
26
    }
27
28
    private function checkHideForm()
29
    {
30
        if (! count($this->hide_form)) {
31
            return null;
32
        }
33
        foreach ($this->form as $i => $f) {
34
            if (in_array($f['name'], $this->hide_form)) {
35
                unset($this->form[$i]);
36
            }
37
        }
38
    }
39
}