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

AbstractTool::disable()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 6

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
nc 1
nop 1
dl 0
loc 6
rs 10
c 0
b 0
f 0
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