Completed
Push — master ( 279d4e...5d09e0 )
by Elf
02:49
created

Builder::tableId()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 0
Metric Value
cc 1
eloc 2
nc 1
nop 1
dl 0
loc 4
ccs 0
cts 4
cp 0
crap 2
rs 10
c 0
b 0
f 0
1
<?php
2
3
namespace ElfSundae\Laravel\Support\Datatables\Html;
4
5
use Yajra\Datatables\Html\Builder as BaseBuilder;
6
7
class Builder extends BaseBuilder
8
{
9
    /**
10
     * Table attributes.
11
     *
12
     * @var array
13
     */
14
    protected $tableAttributes = [
15
        'id' => 'dataTable',
16
        'class' => 'table table-bordered table-hover dt-responsive',
17
        'width' => '100%',
18
    ];
19
20
    /**
21
     * Set table "id" attribute.
22
     *
23
     * @param  string  $id
24
     * @return $this
25
     */
26
    public function tableId($id)
27
    {
28
        return $this->setTableAttribute('id', $id);
29
    }
30
31
    /**
32
     * Change table style to striped.
33
     *
34
     * @return $this
35
     */
36 View Code Duplication
    public function stripedTable()
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
37
    {
38
        if (! str_contains($this->tableAttributes['class'], 'table-striped')) {
39
            $this->tableAttributes['class'] = str_replace(
40
                'table-hover', '',
41
                $this->tableAttributes['class'].' table-striped'
42
            );
43
        }
44
45
        return $this;
46
    }
47
48
    /**
49
     * Change table style to hovered.
50
     *
51
     * @return $this
52
     */
53 View Code Duplication
    public function hoveredTable()
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
54
    {
55
        if (! str_contains($this->tableAttributes['class'], 'table-hover')) {
56
            $this->tableAttributes['class'] = str_replace(
57
                'table-striped', '',
58
                $this->tableAttributes['class'].' table-hover'
59
            );
60
        }
61
62
        return $this;
63
    }
64
}
65