Completed
Push — master ( 1c3c2e...248014 )
by Arjay
10:57
created

Buttons::buttons()   A

Complexity

Conditions 3
Paths 3

Size

Total Lines 8

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 8
rs 10
c 0
b 0
f 0
cc 3
nc 3
nop 1
1
<?php
2
3
namespace Yajra\DataTables\Html\Options\Plugins;
4
5
use Illuminate\Contracts\Support\Arrayable;
6
7
/**
8
 * DataTables - Buttons plugin option builder.
9
 *
10
 * @see https://datatables.net/extensions/buttons/
11
 * @see https://datatables.net/reference/option/buttons
12
 */
13
trait Buttons
14
{
15
    /**
16
     * Attach multiple buttons to builder.
17
     *
18
     * @param mixed ...$buttons
19
     * @return $this
20
     * @see https://www.datatables.net/extensions/buttons/
21
     */
22
    public function buttons(...$buttons)
23
    {
24
        foreach ($buttons as $button) {
25
            $this->attributes['buttons'][] = $button instanceof Arrayable ? $button->toArray() : $button;
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...
26
        }
27
28
        return $this;
29
    }
30
}
31