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

HasHeader   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 37
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 1

Importance

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

2 Methods

Rating   Name   Duplication   Size   Complexity  
A header() 0 10 2
A renderHeader() 0 8 2
1
<?php
2
3
namespace Encore\Admin\Grid\Concerns;
4
5
use Closure;
6
use Encore\Admin\Grid\Tools\Header;
7
8
trait HasHeader
9
{
10
    /**
11
     * @var Closure
12
     */
13
    protected $header;
14
15
    /**
16
     * Set grid header.
17
     *
18
     * @param Closure|null $closure
19
     *
20
     * @return $this|Closure
21
     */
22
    public function header(Closure $closure = null)
23
    {
24
        if (!$closure) {
25
            return $this->header;
26
        }
27
28
        $this->header = $closure;
29
30
        return $this;
31
    }
32
33
    /**
34
     * @return string
35
     */
36
    public function renderHeader()
37
    {
38
        if (!$this->header) {
39
            return '';
40
        }
41
42
        return (new Header($this))->render();
43
    }
44
}