Action::addAction()   A
last analyzed

Complexity

Conditions 2
Paths 2

Size

Total Lines 23

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 23
rs 9.552
c 0
b 0
f 0
cc 2
nc 2
nop 2
1
<?php
2
3
namespace Yajra\DataTables\Html\Columns;
4
5
use Yajra\DataTables\Html\Column;
6
7
trait Action
8
{
9
    /**
10
     * Add a action column.
11
     *
12
     * @param  array $attributes
13
     * @param  bool $prepend
14
     * @return $this
15
     */
16
    public function addAction(array $attributes = [], $prepend = false)
17
    {
18
        $attributes = array_merge([
19
            'defaultContent' => '',
20
            'data' => 'action',
21
            'name' => 'action',
22
            'title' => 'Action',
23
            'render' => null,
24
            'orderable' => false,
25
            'searchable' => false,
26
            'exportable' => false,
27
            'printable' => true,
28
            'footer' => '',
29
        ], $attributes);
30
31
        if ($prepend) {
32
            $this->collection->prepend(new Column($attributes));
0 ignored issues
show
Bug introduced by
The property collection 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...
33
        } else {
34
            $this->collection->push(new Column($attributes));
35
        }
36
37
        return $this;
38
    }
39
}
40