Action   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 33
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 1

Importance

Changes 0
Metric Value
wmc 2
lcom 1
cbo 1
dl 0
loc 33
rs 10
c 0
b 0
f 0

1 Method

Rating   Name   Duplication   Size   Complexity  
A addAction() 0 23 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