DataTableHtml   A
last analyzed

Complexity

Total Complexity 6

Size/Duplication

Total Lines 53
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 0

Importance

Changes 0
Metric Value
wmc 6
lcom 1
cbo 0
dl 0
loc 53
rs 10
c 0
b 0
f 0

4 Methods

Rating   Name   Duplication   Size   Complexity  
A make() 0 4 1
A __call() 0 8 2
A getHtmlBuilder() 0 8 2
A setHtmlBuilder() 0 6 1
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