Completed
Push — master ( 732c1c...de71db )
by Arjay
21s queued 11s
created

DataTableHtml::__call()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 8

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 8
rs 10
c 0
b 0
f 0
cc 2
nc 2
nop 2
1
<?php
2
3
namespace Yajra\DataTables\Html;
4
5
use BadMethodCallException;
6
use Yajra\DataTables\Contracts\DataTableHtmlBuilder;
7
8
/**
9
 * @mixin Builder
10
 */
11
abstract class DataTableHtml implements DataTableHtmlBuilder
12
{
13
    /**
14
     * @var \Yajra\DataTables\Html\Builder
15
     */
16
    protected $htmlBuilder;
17
18
    /**
19
     * @return \Yajra\DataTables\Html\Builder
20
     */
21
    public static function make()
22
    {
23
        return app(static::class)->handle();
24
    }
25
26
    /**
27
     * @param string $name
28
     * @param mixed $arguments
29
     * @return mixed
30
     * @throws \Exception
31
     */
32
    public function __call($name, $arguments)
33
    {
34
        if (method_exists($this->getHtmlBuilder(), $name)) {
35
            return $this->getHtmlBuilder()->{$name}(...$arguments);
36
        }
37
38
        throw new BadMethodCallException("Method {$name} does not exists");
39
    }
40
41
    /**
42
     * @return \Yajra\DataTables\Html\Builder
43
     */
44
    protected function getHtmlBuilder()
45
    {
46
        if ($this->htmlBuilder) {
47
            return $this->htmlBuilder;
48
        }
49
50
        return $this->htmlBuilder = app(Builder::class);
51
    }
52
53
    /**
54
     * @param mixed $builder
55
     * @return static
56
     */
57
    public function setHtmlBuilder($builder)
58
    {
59
        $this->htmlBuilder = $builder;
60
61
        return $this;
62
    }
63
}
64