Buttons   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 22
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 1

Importance

Changes 0
Metric Value
wmc 4
lcom 1
cbo 1
dl 0
loc 22
rs 10
c 0
b 0
f 0

1 Method

Rating   Name   Duplication   Size   Complexity  
A buttons() 0 12 4
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 array|mixed ...$buttons
19
     * @return $this
20
     * @see https://www.datatables.net/extensions/buttons/
21
     */
22
    public function buttons(...$buttons)
23
    {
24
        if (is_array($buttons[0])) {
25
            $buttons = $buttons[0];
26
        }
27
28
        foreach ($buttons as $button) {
29
            $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...
30
        }
31
32
        return $this;
33
    }
34
}
35