Completed
Push — master ( 71797f...8f0aef )
by Song
02:24
created

Expand::addRenderableModalScript()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 26

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
nc 1
nop 0
dl 0
loc 26
rs 9.504
c 0
b 0
f 0
1
<?php
2
3
namespace Encore\Admin\Grid\Displayers;
4
5
use Encore\Admin\Admin;
6
use Encore\Admin\Grid\Simple;
7
use Illuminate\Contracts\Support\Renderable;
8
9
class Expand extends AbstractDisplayer
10
{
11
    protected $renderable;
12
13
    public function display($callback = null, $isExpand = false)
14
    {
15
        $html = '';
16
        $async = false;
17
        $loadGrid = false;
18
19
        if (is_subclass_of($callback, Renderable::class)) {
0 ignored issues
show
Bug introduced by
Due to PHP Bug #53727, is_subclass_of might return inconsistent results on some PHP versions if \Illuminate\Contracts\Support\Renderable::class can be an interface. If so, you could instead use ReflectionClass::implementsInterface.
Loading history...
20
            $this->renderable = $callback;
21
            $async = true;
22
            $loadGrid = is_subclass_of($callback, Simple::class);
0 ignored issues
show
Bug introduced by
Due to PHP Bug #53727, is_subclass_of might return inconsistent results on some PHP versions if \Encore\Admin\Grid\Simple::class can be an interface. If so, you could instead use ReflectionClass::implementsInterface.
Loading history...
23
        } else {
24
            $html = call_user_func_array($callback->bindTo($this->row), [$this->row]);
25
        }
26
27
        return Admin::component('admin::components.column-expand', [
28
            'key'           => $this->getKey(),
29
            'url'           => $this->getLoadUrl(),
30
            'name'          => $this->column->getName() . '-' . $this->getKey(),
31
            'html'          => $html,
32
            'value'         => $this->value,
33
            'async'         => $async,
34
            'expand'        => $isExpand,
35
            'loadGrid'      => $loadGrid,
36
            'elementClass'  => "grid-expand-{$this->grid->getGridRowName()}",
37
        ]);
38
    }
39
40
    /**
41
     * @param int $multiple
0 ignored issues
show
Bug introduced by
There is no parameter named $multiple. Was it maybe removed?

This check looks for PHPDoc comments describing methods or function parameters that do not exist on the corresponding method or function.

Consider the following example. The parameter $italy is not defined by the method finale(...).

/**
 * @param array $germany
 * @param array $island
 * @param array $italy
 */
function finale($germany, $island) {
    return "2:1";
}

The most likely cause is that the parameter was removed, but the annotation was not.

Loading history...
42
     *
43
     * @return string
44
     */
45
    protected function getLoadUrl()
46
    {
47
        $renderable = str_replace('\\', '_', $this->renderable);
48
49
        return route('admin.handle-renderable', compact('renderable'));
50
    }
51
}
52