Completed
Push — master ( c6a049...7f7ede )
by Song
03:29
created

HasFooter::footer()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 10

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 2
nc 2
nop 1
dl 0
loc 10
rs 9.9332
c 0
b 0
f 0
1
<?php
2
3
namespace Encore\Admin\Grid\Concerns;
4
5
use Closure;
6
use Encore\Admin\Grid\Tools\Footer;
7
8
trait HasFooter
9
{
10
    /**
11
     * @var Closure
12
     */
13
    protected $footer;
14
15
    /**
16
     * Set grid footer.
17
     *
18
     * @param Closure|null $closure
19
     *
20
     * @return $this|Closure
21
     */
22
    public function footer(Closure $closure = null)
23
    {
24
        if (!$closure) {
25
            return $this->footer;
26
        }
27
28
        $this->footer = $closure;
29
30
        return $this;
31
    }
32
33
    /**
34
     * Render grid footer.
35
     *
36
     * @return string
37
     */
38
    public function renderFooter()
39
    {
40
        if (!$this->footer) {
41
            return '';
42
        }
43
44
        return (new Footer($this))->render();
45
    }
46
}