Completed
Pull Request — master (#3054)
by
unknown
02:23
created

AbstractTool   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 61
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 0

Importance

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

5 Methods

Rating   Name   Duplication   Size   Complexity  
A disable() 0 6 1
A allowed() 0 4 1
A setGrid() 0 6 1
render() 0 1 ?
A __toString() 0 4 1
1
<?php
2
3
namespace Encore\Admin\Grid\Tools;
4
5
use Encore\Admin\Grid;
6
use Illuminate\Contracts\Support\Renderable;
7
8
abstract class AbstractTool implements Renderable
9
{
10
    /**
11
     * @var Grid
12
     */
13
    protected $grid;
14
15
    /**
16
     * @var bool
17
     */
18
    protected $disabled = false;
19
20
    /**
21
     * Toggle this button.
22
     *
23
     * @param bool $disable
24
     *
25
     * @return $this
26
     */
27
    public function disable(bool $disable = true)
28
    {
29
        $this->disabled = $disable;
30
31
        return $this;
32
    }
33
34
    /**
35
     * If the tool is allowed.
36
     */
37
    public function allowed()
38
    {
39
        return !$this->disabled;
40
    }
41
42
    /**
43
     * Set parent grid.
44
     *
45
     * @param Grid $grid
46
     *
47
     * @return $this
48
     */
49
    public function setGrid(Grid $grid)
50
    {
51
        $this->grid = $grid;
52
53
        return $this;
54
    }
55
56
    /**
57
     * {@inheritdoc}
58
     */
59
    abstract public function render();
60
61
    /**
62
     * @return string
63
     */
64
    public function __toString()
65
    {
66
        return $this->render();
67
    }
68
}
69