SearchPanes::searchPanes()   A
last analyzed

Complexity

Conditions 4
Paths 8

Size

Total Lines 18

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 18
rs 9.6666
c 0
b 0
f 0
cc 4
nc 8
nop 1
1
<?php
2
3
namespace Yajra\DataTables\Html\Options\Plugins;
4
5
use Yajra\DataTables\Html\SearchPane;
6
use Illuminate\Contracts\Support\Arrayable;
7
8
/**
9
 * DataTables - Search panes plugin option builder.
10
 *
11
 * @see https://datatables.net/extensions/searchpanes
12
 * @see https://datatables.net/reference/option/searchPanes
13
 */
14
trait SearchPanes
15
{
16
    /**
17
     * Set searchPane option value.
18
     *
19
     * @param bool|array $value
20
     * @return $this
21
     * @see https://datatables.net/reference/option/searchPanes
22
     */
23
    public function searchPanes($value = true)
24
    {
25
        if (is_callable($value)) {
26
            $value = app()->call($value);
27
        }
28
29
        if ($value instanceof Arrayable) {
30
            $value = $value->toArray();
31
        }
32
33
        if (is_bool($value)) {
34
            $value = SearchPane::make()->show($value)->toArray();
35
        }
36
37
        $this->attributes['searchPanes'] = $value;
0 ignored issues
show
Bug introduced by
The property attributes does not exist. Did you maybe forget to declare it?

In PHP it is possible to write to properties without declaring them. For example, the following is perfectly valid PHP code:

class MyClass { }

$x = new MyClass();
$x->foo = true;

Generally, it is a good practice to explictly declare properties to avoid accidental typos and provide IDE auto-completion:

class MyClass {
    public $foo;
}

$x = new MyClass();
$x->foo = true;
Loading history...
38
39
        return $this;
40
    }
41
}
42