Completed
Pull Request — master (#4171)
by Muhlis
09:37
created

Divider::note()   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 0
dl 0
loc 6
rs 10
c 0
b 0
f 0
1
<?php
2
3
namespace Encore\Admin\Form\Field;
4
5
use Encore\Admin\Form\Field;
6
7
class Divider extends Field
8
{
9
    protected $title;
10
    protected $class = 'divider';
11
12
    public function __construct($title = '')
13
    {
14
        $this->title = $title;
15
    }
16
17
    public function render()
18
    {
19
        if (empty($this->title)) {
20
            return '<hr>';
21
        }
22
23
        return <<<HTML
24
<div class="{$this->class}">
25
  <span class="$this->class-title">
26
    {$this->title}
27
  </span>
28
</div>
29
HTML;
30
    }
31
32
    /**
33
     * Add note style for divider.
34
     *
35
     * @return $this
36
     */
37
    public function note()
38
    {
39
        $this->class = 'note';
40
41
        return $this;
42
    }
43
}
44