Passed
Push — master ( d63a45...8016ac )
by Iman
09:10
created

CbFormLoader   A

Complexity

Total Complexity 5

Size/Duplication

Total Lines 29
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
dl 0
loc 29
rs 10
c 0
b 0
f 0
wmc 5

2 Methods

Rating   Name   Duplication   Size   Complexity  
A checkHideForm() 0 8 4
A cbFormLoader() 0 7 1
1
<?php
2
3
namespace Crocodicstudio\Crudbooster\Controllers\CBController;
4
5
trait CbFormLoader
6
{
7
    public $data_inputan;
8
9
    public $hide_form = [];
10
11
    public $buttonCancel = true;
12
13
    public $button_save = true;
14
15
    public $addMoreButton = true;
16
17
    protected function cbFormLoader()
18
    {
19
        $this->data_inputan = $this->form;
20
        $this->data['forms'] = $this->data_inputan;
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...
21
        $this->data['addMoreButton'] = $this->addMoreButton;
22
        $this->data['buttonCancel'] = $this->buttonCancel;
23
        $this->data['button_save'] = $this->button_save;
24
    }
25
26
    private function checkHideForm()
27
    {
28
        if (! count($this->hide_form)) {
29
            return null;
30
        }
31
        foreach ($this->form as $i => $f) {
32
            if (in_array($f['name'], $this->hide_form)) {
33
                unset($this->form[$i]);
34
            }
35
        }
36
    }
37
}