Completed
Pull Request — master (#5)
by ARCANEDEV
05:08
created

Builder   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 53
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 3

Test Coverage

Coverage 66.67%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 3
c 1
b 0
f 0
lcom 0
cbo 3
dl 0
loc 53
ccs 4
cts 6
cp 0.6667
rs 10

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __call() 0 11 2
A toHtmlString() 0 4 1
1
<?php namespace Arcanedev\LaravelHtml\Bases;
2
3
use Arcanedev\LaravelHtml\Traits\Componentable;
4
use BadMethodCallException;
5
use Illuminate\Support\HtmlString;
6
use Illuminate\Support\Traits\Macroable;
7
8
/**
9
 * Class     Builder
10
 *
11
 * @package  Arcanedev\LaravelHtml\Bases
12
 * @author   ARCANEDEV <[email protected]>
13
 */
14
abstract class Builder
15
{
16
    /* ------------------------------------------------------------------------------------------------
17
     |  Traits
18
     | ------------------------------------------------------------------------------------------------
19
     */
20
    use Macroable, Componentable {
21
        Macroable::__call     as macroCall;
22
        Componentable::__call as componentCall;
23
    }
24
25
    /* ------------------------------------------------------------------------------------------------
26
     |  Main Functions
27
     | ------------------------------------------------------------------------------------------------
28
     */
29
    /**
30
     * Dynamically handle calls to the class.
31
     *
32
     * @param  string  $method
33
     * @param  array   $parameters
34
     *
35
     * @return \Illuminate\Contracts\View\View|mixed
36
     *
37
     * @throws \BadMethodCallException
38
     */
39 8
    public function __call($method, $parameters)
40
    {
41
        try {
42 8
            return $this->componentCall($method, $parameters);
43
        }
44
        catch (BadMethodCallException $e) {
45
            // Continue
46
        }
47
48
        return $this->macroCall($method, $parameters);
49
    }
50
51
    /* ------------------------------------------------------------------------------------------------
52
     |  Other Functions
53
     | ------------------------------------------------------------------------------------------------
54
     */
55
    /**
56
     * Transform the string to an Html serializable object
57
     *
58
     * @param  string  $html
59
     *
60
     * @return \Illuminate\Support\HtmlString
61
     */
62 944
    protected function toHtmlString($html)
63
    {
64 944
        return new HtmlString($html);
65
    }
66
}
67