Completed
Push — master ( 024746...0b49f1 )
by Song
04:00
created

BatchAction   A

Complexity

Total Complexity 7

Size/Duplication

Total Lines 82
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 1

Importance

Changes 0
Metric Value
dl 0
loc 82
rs 10
c 0
b 0
f 0
wmc 7
lcom 1
cbo 1

7 Methods

Rating   Name   Duplication   Size   Complexity  
A setId() 0 4 1
A setTitle() 0 6 1
A getTitle() 0 4 1
A setGrid() 0 6 1
A getToken() 0 4 1
A getElementClass() 0 9 2
script() 0 1 ?
1
<?php
2
3
namespace Encore\Admin\Grid\Tools;
4
5
use Encore\Admin\Grid;
6
7
abstract class BatchAction
8
{
9
    /**
10
     * @var integer
11
     */
12
    protected $id;
13
14
    /**
15
     * @var string
16
     */
17
    protected $title;
18
19
    /**
20
     * @var string
21
     */
22
    protected $resource;
23
24
    /**
25
     * @var Grid
26
     */
27
    protected $grid;
28
29
    /**
30
     * @param $id
31
     */
32
    public function setId($id)
33
    {
34
        $this->id = $id;
35
    }
36
37
    public function setTitle($title)
38
    {
39
        $this->title = $title;
40
41
        return $this;
42
    }
43
44
    /**
45
     * @return string
46
     */
47
    public function getTitle()
48
    {
49
        return $this->title;
50
    }
51
52
    /**
53
     * @param Grid $grid
54
     */
55
    public function setGrid(Grid $grid)
56
    {
57
        $this->grid = $grid;
58
59
        $this->resource = $grid->resource();
60
    }
61
62
    /**
63
     * @return string
64
     */
65
    public function getToken()
66
    {
67
        return csrf_token();
68
    }
69
70
    /**
71
     * @param bool $dotPrefix
72
     * @return string
73
     */
74
    public function getElementClass($dotPrefix = true)
75
    {
76
        return sprintf(
77
            '%s%s-%s',
78
            $dotPrefix ? '.' : '',
79
            $this->grid->getGridBatchName(),
80
            $this->id
81
        );
82
    }
83
84
    /**
85
     * @return mixed
86
     */
87
    abstract public function script();
88
}
89