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

Simple::render()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 18

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
nc 1
nop 1
dl 0
loc 18
rs 9.6666
c 0
b 0
f 0
1
<?php
2
3
namespace Encore\Admin\Grid;
4
5
use Encore\Admin\Grid;
6
use Illuminate\Contracts\Support\Renderable;
7
8
/**
9
 * @mixin Grid
10
 */
11
class Simple implements Renderable
12
{
13
    /**
14
     * @var Grid
15
     */
16
    protected $grid;
17
18
    /**
19
     * @var string
20
     */
21
    protected $model;
22
23
    /**
24
     * @param null $key
25
     * @return string
26
     */
27
    public function render($key = null)
28
    {
29
        $this->grid = new Grid(new $this->model);
30
31
        $this->make($key);
0 ignored issues
show
Documentation Bug introduced by
The method make does not exist on object<Encore\Admin\Grid\Simple>? Since you implemented __call, maybe consider adding a @method annotation.

If you implement __call and you know which methods are available, you can improve IDE auto-completion and static analysis by adding a @method annotation to the class.

This is often the case, when __call is implemented by a parent class and only the child class knows which methods exist:

class ParentClass {
    private $data = array();

    public function __call($method, array $args) {
        if (0 === strpos($method, 'get')) {
            return $this->data[strtolower(substr($method, 3))];
        }

        throw new \LogicException(sprintf('Unsupported method: %s', $method));
    }
}

/**
 * If this class knows which fields exist, you can specify the methods here:
 *
 * @method string getName()
 */
class SomeClass extends ParentClass { }
Loading history...
32
33
        return $this->grid
34
            ->disableActions()
35
            ->disableBatchActions()
36
            ->disableExport()
37
            ->disableColumnSelector()
38
            ->disableCreateButton()
39
            ->disablePerPageSelector()
40
            ->paginate(10)
41
            ->expandFilter()
42
            ->render()
43
        ;
44
    }
45
46
    /**
47
     * @param string $name
48
     * @param array  $arguments
49
     * @return mixed
50
     */
51
    public function __call($name, $arguments)
52
    {
53
        return call_user_func_array([$this->grid, $name], $arguments);
54
    }
55
}