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
|
|
|
|
21
|
|
|
use Macroable, Componentable { |
22
|
|
|
Macroable::__call as macroCall; |
23
|
|
|
Componentable::__call as componentCall; |
24
|
|
|
} |
25
|
|
|
|
26
|
|
|
/* ----------------------------------------------------------------- |
27
|
|
|
| Main Methods |
28
|
|
|
| ----------------------------------------------------------------- |
29
|
|
|
*/ |
30
|
|
|
|
31
|
|
|
/** |
32
|
|
|
* Dynamically handle calls to the class. |
33
|
|
|
* |
34
|
|
|
* @param string $method |
35
|
|
|
* @param array $parameters |
36
|
|
|
* |
37
|
|
|
* @return \Illuminate\Contracts\View\View|mixed |
38
|
|
|
* |
39
|
|
|
* @throws \BadMethodCallException |
40
|
|
|
*/ |
41
|
6 |
|
public function __call($method, $parameters) |
42
|
|
|
{ |
43
|
|
|
try { |
44
|
6 |
|
return $this->componentCall($method, $parameters); |
45
|
|
|
} |
46
|
3 |
|
catch (BadMethodCallException $e) { |
47
|
|
|
// Continue |
48
|
|
|
} |
49
|
|
|
|
50
|
3 |
|
return $this->macroCall($method, $parameters); |
51
|
|
|
} |
52
|
|
|
|
53
|
|
|
/* ----------------------------------------------------------------- |
54
|
|
|
| Other Methods |
55
|
|
|
| ----------------------------------------------------------------- |
56
|
|
|
*/ |
57
|
|
|
|
58
|
|
|
/** |
59
|
|
|
* Transform the string to an Html serializable object |
60
|
|
|
* |
61
|
|
|
* @param string $html |
62
|
|
|
* |
63
|
|
|
* @return \Illuminate\Support\HtmlString |
64
|
|
|
*/ |
65
|
|
|
protected function toHtmlString($html) |
66
|
|
|
{ |
67
|
|
|
return new HtmlString($html); |
68
|
|
|
} |
69
|
|
|
} |
70
|
|
|
|