Completed
Push — master ( 5fc65a...affc4f )
by Song
02:25
created

Help   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 43
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 2

Importance

Changes 0
Metric Value
dl 0
loc 43
rs 10
c 0
b 0
f 0
wmc 2
lcom 1
cbo 2

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 4 1
A render() 0 20 1
1
<?php
2
3
namespace Encore\Admin\Grid\Column;
4
5
use Encore\Admin\Admin;
6
use Illuminate\Contracts\Support\Renderable;
7
8
class Help implements Renderable
9
{
10
    /**
11
     * @var string
12
     */
13
    protected $message = '';
14
15
    /**
16
     * Help constructor.
17
     *
18
     * @param string $message
19
     */
20
    public function __construct($message = '')
21
    {
22
        $this->message = $message;
23
    }
24
25
    /**
26
     * Render help  header.
27
     *
28
     * @return string
29
     */
30
    public function render()
31
    {
32
        Admin::script("$('.grid-column-help').tooltip();");
33
34
        $data = [
35
            'toggle'    => 'tooltip',
36
            'placement' => 'top',
37
            'title'     => $this->message,
38
        ];
39
40
        $data = collect($data)->map(function ($val, $key) {
41
            return "data-{$key}=\"{$val}\"";
42
        })->implode(' ');
43
44
        return <<<HELP
45
<a href="javascript:void(0);" class="grid-column-help" {$data}>
46
    <i class="fa fa-question-circle"></i>
47
</a>
48
HELP;
49
    }
50
}