Total Complexity | 5 |
Total Lines | 55 |
Duplicated Lines | 0 % |
Changes | 1 | ||
Bugs | 0 | Features | 0 |
1 | <?php |
||
9 | abstract class Component extends BaseComponent |
||
10 | { |
||
11 | /** |
||
12 | * ID for this component. |
||
13 | * |
||
14 | * @var string |
||
15 | */ |
||
16 | private $id; |
||
17 | |||
18 | /** |
||
19 | * {@inheritDoc} |
||
20 | */ |
||
21 | public function render() |
||
22 | { |
||
23 | $alias = Str::kebab(class_basename($this)); |
||
24 | |||
25 | $config = config("form-components.components.{$alias}"); |
||
26 | |||
27 | $framework = config("form-components.framework"); |
||
28 | |||
29 | return str_replace('{framework}', $framework, $config['view']); |
||
30 | } |
||
31 | |||
32 | /** |
||
33 | * Returns a boolean wether the form is wired to a Livewire component. |
||
34 | * |
||
35 | * @return boolean |
||
36 | */ |
||
37 | public function isWired(): bool |
||
38 | { |
||
39 | return app(FormDataBinder::class)->isWired(); |
||
40 | } |
||
41 | |||
42 | /** |
||
43 | * The inversion of 'isWired()'. |
||
44 | * |
||
45 | * @return boolean |
||
46 | */ |
||
47 | public function isNotWired(): bool |
||
48 | { |
||
49 | return !$this->isWired(); |
||
50 | } |
||
51 | |||
52 | /** |
||
53 | * Generates an ID, once, for this component. |
||
54 | * |
||
55 | * @return string |
||
56 | */ |
||
57 | public function id(): string |
||
64 | } |
||
65 | } |
||
66 |