Completed
Push — master ( 161fc8...c8b749 )
by Song
02:30
created

QRCode::display()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 19

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 2
nc 2
nop 3
dl 0
loc 19
rs 9.6333
c 0
b 0
f 0
1
<?php
2
3
namespace Encore\Admin\Grid\Displayers;
4
5
use Encore\Admin\Facades\Admin;
6
7
/**
8
 * Class QRCode
9
 *
10
 * @package Encore\Admin\Grid\Displayers
11
 */
12
class QRCode extends AbstractDisplayer
13
{
14
    protected function addScript()
15
    {
16
        $script = <<<SCRIPT
17
$('.grid-column-qrcode').popover({
18
    html: true,
19
    trigger: 'focus'
20
});
21
SCRIPT;
22
23
        Admin::script($script);
24
    }
25
26
    public function display($formatter = null, $width = 150, $height = 150)
27
    {
28
        $this->addScript();
29
30
        $content = $this->getColumn()->getOriginal();
31
32
        if ($formatter instanceof \Closure) {
33
            $content = call_user_func($formatter, $content, $this->row);
34
        }
35
36
        $img = "<img src='https://api.qrserver.com/v1/create-qr-code/?size={$width}x{$height}&data={$content}' style='height: {$width}px;width: {$height}px;'/>";
37
38
        return <<<HTML
39
<a href="javascript:void(0);" class="grid-column-qrcode text-muted" data-content="{$img}" data-toggle='popover' tabindex='0'>
40
    <i class="fa fa-qrcode"></i>
41
</a>&nbsp;&nbsp;{$this->getValue()}
42
HTML;
43
HTML;
0 ignored issues
show
Unused Code introduced by
HTML; does not seem to be reachable.

This check looks for unreachable code. It uses sophisticated control flow analysis techniques to find statements which will never be executed.

Unreachable code is most often the result of return, die or exit statements that have been added for debug purposes.

function fx() {
    try {
        doSomething();
        return true;
    }
    catch (\Exception $e) {
        return false;
    }

    return false;
}

In the above example, the last return false will never be executed, because a return statement has already been met in every possible execution path.

Loading history...
44
    }
45
}