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

AbstractTool::allowed()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
nc 1
nop 0
dl 0
loc 4
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 boolean
17
     */
18
    protected $disabled = false;
19
20
    /**
21
     * Toggle this button.
22
     *
23
     * @param bool $disable
24
     * @return $this
25
     */
26
    public function disable(bool $disable = true)
27
    {
28
        $this->disabled = $disable;
29
30
        return $this;
31
    }
32
33
    /**
34
     * If the tool is allowed.
35
     */
36
    public function allowed()
37
    {
38
        return !$this->disabled;
39
    }
40
41
    /**
42
     * Set parent grid.
43
     *
44
     * @param Grid $grid
45
     *
46
     * @return $this
47
     */
48
    public function setGrid(Grid $grid)
49
    {
50
        $this->grid = $grid;
51
52
        return $this;
53
    }
54
55
    /**
56
     * {@inheritdoc}
57
     */
58
    abstract public function render();
59
60
    /**
61
     * @return string
62
     */
63
    public function __toString()
64
    {
65
        return $this->render();
66
    }
67
}
68